# N00b question: Sort pages by weight

**URL:** <https://zola.discourse.group/t/n00b-question-sort-pages-by-weight/514>\
**Category:** Support\
**Created:** [July 27, 2020, 3:55pm UTC](https://zola.discourse.group/t/n00b-question-sort-pages-by-weight/514 "2020-07-27T15:55:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bronzehedwick](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/bronzehedwick/32/275_2.png) [@bronzehedwick](https://zola.discourse.group/u/bronzehedwick)\
**Post date:** [July 27, 2020, 3:55pm UTC](https://zola.discourse.group/t/n00b-question-sort-pages-by-weight/514/1 "2020-07-27T15:55:41Z")

</div>

Hi all, I’m new to Zola but have experience with Twig and Hugo. Having a very embarrassing problem: I’m trying to loop over every page in Tera and sort them by weight, but I get an error. My code:

```auto
{% for page in pages|sort(attribute="weight") %}
  {# print page #}
{% endfor %}

```

I’m not sure what I’m doing wrong, and I couldn’t find any documentation that provided any more insight.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [July 28, 2020, 10:05am UTC](https://zola.discourse.group/t/n00b-question-sort-pages-by-weight/514/2 "2020-07-28T10:05:46Z")

</div>

If you say in the parent section that you want them sorted by weight (`sort_by = "weight"`), it will be sorted automatically.

---

<div class="post-metadata">

**Author:** ![bronzehedwick](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/bronzehedwick/32/275_2.png) [@bronzehedwick](https://zola.discourse.group/u/bronzehedwick)\
**Post date:** [July 28, 2020, 3:31pm UTC](https://zola.discourse.group/t/n00b-question-sort-pages-by-weight/514/3 "2020-07-28T15:31:08Z")

</div>

Oh interesting, thanks for the reply. This will actually solve my current use case, but out of curiosity, is there a way to print pages with multiple sorts inside the same section?

For instance, say I’m using weighted sort plus another condition to print menu items (e.g. `menu = true`), and then in that same section print date sorted article pages in the main content.

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [July 28, 2020, 4:18pm UTC](https://zola.discourse.group/t/n00b-question-sort-pages-by-weight/514/4 "2020-07-28T16:18:30Z")

</div>

If you don’t use pagination, you can just use something like:

```auto
{% for page in pages %}
  {% if page.extra.menu %}
    {{page.title}}
  {% endif %}
{% endfor %}

```
