<p>You don't mention where you tried putting the <code>reverse</code> filter, but perhaps you put it in the wrong place? It should go here:</p>

<p><code>{% set entriesByYear = entries|reverse|group('postDate.year') %}</code></p>

<p>I've tested this and it works ok for me.</p>

CC BY-SA 4.0
2020-05-28T10:28:12.567Z
i am wondering why orderBy to desc is not working in question though?
user9975
CC BY-SA 4.0
2020-05-28T09:36:04.377Z
2020-05-28T09:36:04.377Z
James Smith
<p>I am trying to apply the group filter so that my year headings appear in DESC order. They are appearing in ASC order instead, and applying |reverse doesn't work. Suggestions?</p>

<pre><code>{% set entries = craft.entries.section('blat')
.orderBy('postDate DESC')
.limit(null)
.with ( ['thumbnail'] )
%}
{% set entriesByYear = entries|group('postDate.year') %}
{% for year, entriesInYear in entriesByYear %}

    &lt;h2&gt;{{ year }}&lt;/h2&gt;

  {% for entry in entriesInYear %}

{% endfor %}
</code></pre>

<templating><entries>
Problem with Twig group function, group by year
# Problem with Twig group function, group by year

(Asked by: username_0 on 2020-05-27)

I am trying to apply the group filter so that my year headings appear in DESC order. They are appearing in ASC order instead, and applying |reverse doesn't work. Suggestions?
{% set entries = craft.entries.section('blat')
.orderBy('postDate DESC')
.limit(null)
.with ( ['thumbnail'] )
%}
{% set entriesByYear = entries|group('postDate.year') %}
{% for year, entriesInYear in entriesByYear %}

    {{ year }}

  {% for entry in entriesInYear %}

{% endfor %}

**Tags:** templating, entries


---

## 1 answers

### Answer by username_1 on 2020-05-28. Score: 2 | Accepted answer

You don't mention where you tried putting the `reverse` filter, but perhaps you put it in the wrong place? It should go here:

`{% set entriesByYear = entries|reverse|group('postDate.year') %}`

I've tested this and it works ok for me.

> **Comments:**
> **username_2**: i am wondering why orderBy to desc is not working in question though?  

---

