# \[support or feature\] ordering range .Site.Data contents

**URL:** <https://discourse.gohugo.io/t/support-or-feature-ordering-range-site-data-contents/6177>\
**Category:** support\
**Created:** [April 14, 2017, 3:41pm UTC](https://discourse.gohugo.io/t/support-or-feature-ordering-range-site-data-contents/6177 "2017-04-14T15:41:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yesh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yesh/32/2998_2.png) [@yesh](https://discourse.gohugo.io/u/yesh)\
**Post date:** [April 14, 2017, 3:41pm UTC](https://discourse.gohugo.io/t/support-or-feature-ordering-range-site-data-contents/6177/1 "2017-04-14T15:41:24Z")

</div>

Hi everyone,

I tried to search for it and I tried the order solution and the sort solutions but I cannot get it to work.

in the data folder I have an erp\_leaft.toml with this data:

```
[branche]
  name = "Lösungen nach Branche"
  short_name = "nach Branche"

  [branche.malerundgipser]
    weight = 0
    name = "Maler und Gipser"
    description = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste deserunt, ducimus..."
    internal_link = "produkte/enterprise/maler-und-gipser"

  [branche.treuhand]
    weight = 1
    name = "Maler und Gipser"
    description = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste deserunt, ducimus..."
    internal_link = "produkte/enterprise/maler-und-gipser"

  [branche.immobilienbewirtschaftung]
    weight = 2
    name = "Immobilienbewirtschaftung"
    description = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste deserunt, du`cimus..."
    internal_link = "produkte/enterprise/maler-und-gipser"

```

and tried to sort the data with .ByWeight and sort “weight” but nothing works. is it not supported or am I doing something wrong?

```
{{ $data := index .Site.Data .Site.Language.Lang }}
  
{{ range sort $data.products.erp_leafs.branche "weight" }}
  {{ .name }}
{{ end }}

```

can someone help me please?

thank you!  
y

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [April 14, 2017, 7:08pm UTC](https://discourse.gohugo.io/t/support-or-feature-ordering-range-site-data-contents/6177/2 "2017-04-14T19:08:46Z")

</div>

So, I don’t think that `.ByWeight` will not work since it is built to reference the `weight` field in the front matter of content files for your pages.

Can you try the following for me?

```auto
{{ $lang := index .Site.Data .Site.Language.Lang }}
{{ range $item, $params := sort ($.Site.Data.erp_leaftl) "weight" }}
    {{ if eq $lang $item }}
      {{ range $item }}
         {{.name}}
      {{ end }}
    {{ end }}
{{ end }}

```

This already looks ugly to me, so I think we might be able to accomplish this better with nested `where` statements. Do you have more of a repo to point me to by any chance?

---

<div class="post-metadata">

**Author:** ![yesh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/yesh/32/2998_2.png) [@yesh](https://discourse.gohugo.io/u/yesh)\
**Post date:** [April 15, 2017, 12:58pm UTC](https://discourse.gohugo.io/t/support-or-feature-ordering-range-site-data-contents/6177/3 "2017-04-15T12:58:58Z")

</div>

hey rdwatters,  
I just found that there was an error with my toml file.

removing the root [branche] solved the issue and I could sort the array by weight.  
I don’t fully understand how toml arrays work yet, so this lead to the issue.

thank you for your response tho.

y
