Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-27T18:40:11.460Z
Answers.LastActivityDate: 2016-08-27T18:40:11.460Z
Answers.UserDisplayName: carlcs
Body: <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>
  
Tags: <templating><ordering>
Title: Yearly/Monthy archive listing sorted by month
ThreadText: # 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") %}
        <div class="col-sm-3 col-xs-6" data-mh="years">
          <h3>{{ year }}</h3>
          <ul class="list-unstyled">
          {% for month, entries in entriesInYear | group("postDate|date('F')" ) %}
              <li><a href="/calendar/{{ year }}/{{ month|date('m') }}">{{ month }}&nbsp;({{ entries|length }})</a></li>
          {% endfor %}
          </ul>
        </div>
    {% 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
  
  [![enter image description here](https://i.sstatic.net/qzz8b.png)](https://i.sstatic.net/qzz8b.png)
  
  **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>
  
  
  ---
  
  