Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-28T10:28:12.567Z
Answers.Text: i am wondering why orderBy to desc is not working in question though?
Answers.UserDisplayName: user9975
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-28T09:36:04.377Z
Answers.LastActivityDate: 2020-05-28T09:36:04.377Z
Answers.UserDisplayName: James Smith
Body: <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>
  
Tags: <templating><entries>
Title: Problem with Twig group function, group by year
ThreadText: # 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 %}
  
      <h2>{{ year }}</h2>
  
    {% 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?  
  
  ---
  
  