<p>Add the <code>reverse</code> filter to your inner array of entries in month.<br>
<a href="http://twig.sensiolabs.org/doc/filters/reverse.html" rel="nofollow">http://twig.sensiolabs.org/doc/filters/reverse.html</a></p>

CC BY-SA 3.0
2016-08-27T18:40:11.460Z
2016-08-27T18:40:11.460Z
carlcs
<p>I've got a list of entries grouped by year which is working correctly except that the months are being output in the the reverse order.</p>

<p>This code outputs the years in the correct order but the months in reverse order:</p>

<pre><code>    {# all entries sorted by year/month #}
     {% set allEntries = craft.entries.section('photoblog').limit(null).order('postDate desc') %}

  {% for year, entriesInYear in allEntries | group("postDate.year") %}
      &lt;div class="col-sm-3 col-xs-6" data-mh="years"&gt;
        &lt;h3&gt;{{ year }}&lt;/h3&gt;
        &lt;ul class="list-unstyled"&gt;
        {% for month, entries in entriesInYear | group("postDate|date('F')" ) %}
            &lt;li&gt;&lt;a href="/calendar/{{ year }}/{{ month|date('m') }}"&gt;{{ month }}&amp;nbsp;({{ entries|length }})&lt;/a&gt;&lt;/li&gt;
        {% endfor %}
        &lt;/ul&gt;
      &lt;/div&gt;
  {% endfor %}
</code></pre>

<p>If I change the '''.order('postDate desc') to asc then the months are in the correct order but the years are reversed. is there a way to get it so that the years are descending but the months are ascending?</p>

<p>screenshot of current code results</p>

<p><a href="https://i.sstatic.net/qzz8b.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qzz8b.png" alt="enter image description here"></a></p>

<templating><ordering>
Yearly/Monthy archive listing sorted by month
# Yearly/Monthy archive listing sorted by month

(Asked by: username_0 on 2016-08-27)

I've got a list of entries grouped by year which is working correctly except that the months are being output in the the reverse order.
This code outputs the years in the correct order but the months in reverse order:
    {# all entries sorted by year/month #}
     {% set allEntries = craft.entries.section('photoblog').limit(null).order('postDate desc') %}

  {% for year, entriesInYear in allEntries | group("postDate.year") %}
      
        {{ year }}
        
        {% for month, entries in entriesInYear | group("postDate|date('F')" ) %}
            {{ month }} ({{ entries|length }})
        {% endfor %}
        
      
  {% endfor %}

If I change the '''.order('postDate desc') to asc then the months are in the correct order but the years are reversed. is there a way to get it so that the years are descending but the months are ascending?
screenshot of current code results

**Tags:** templating, ordering

---

## 1 answers

### Answer by username_1 on 2016-08-27. Score: 3 | Accepted answer

Add the `reverse` filter to your inner array of entries in month.  
<http://twig.sensiolabs.org/doc/filters/reverse.html>


---

