<p>The suggestion to order by sectionId resolved my issue here. </p>

<p>{% set entries = craft.entries().section('extendedEvents, festivalEvents'). orderBy({sectionId: SORT_ASC}) %}</p>

<p>As it was, I was working with two sections, so my quick fix was to simply reverse the order of the output of the for loop...</p>

<p>{% for section, eventsInSection in allEventsBySection | reverse %}                          </p>

CC BY-SA 4.0
2019-03-28T12:27:35.033Z
2019-03-28T12:27:35.033Z
Kevin
<p>Im grabbing entries from two sections and displaying them using the group filter. </p>

<pre><code>{% set entries = craft.entries().section('extendedEvents, festivalEvents')%}
{% set allEvents = entries %}
{% set allEventsBySection = allEvents|group('section') %}

{% for section, eventsInSection in allEventsBySection %}
- results- 
{% endfor %}
</code></pre>

<p>No matter what I do the results are coming back ordered as section2 (entry, entry, entry) then section 1 (entry, entry, entry)</p>

<p>How do I affect the order of the sections when displaying the results?                      </p>

CC BY-SA 4.0
2019-03-12T16:48:10.130Z
Not sure if I got it wrong but what is your goal exactly? Ordering by `orderBy({sectionId: SORT_ASC})` in your main Query?
Robin Schambach
CC BY-SA 4.0
2019-03-12T17:31:29.027Z
Thanks, that worked - as there were only two sections I just reversed the arrays in the for loop which also did the job
Kevin
CC BY-SA 4.0
2019-03-13T22:04:07.447Z
@Kevin Can you add your solution as an official answer? Might end up helping someone in the future.
Brad Bell
<templating><filter><ordering><group>
Grouping entries and ordering by section
# Grouping entries and ordering by section

(Asked by: username_0 on 2019-03-12)

Im grabbing entries from two sections and displaying them using the group filter. 
{% set entries = craft.entries().section('extendedEvents, festivalEvents')%}
{% set allEvents = entries %}
{% set allEventsBySection = allEvents|group('section') %}

{% for section, eventsInSection in allEventsBySection %}
- results- 
{% endfor %}

No matter what I do the results are coming back ordered as section2 (entry, entry, entry) then section 1 (entry, entry, entry)
How do I affect the order of the sections when displaying the results?

**Tags:** templating, filter, ordering, group
> **Comments:**
> **username_1**: Not sure if I got it wrong but what is your goal exactly? Ordering by `orderBy({sectionId: SORT_ASC})` in your main Query?  
> **username_0**: Thanks, that worked - as there were only two sections I just reversed the arrays in the for loop which also did the job  
> **username_2**: @Kevin Can you add your solution as an official answer? Might end up helping someone in the future.  

---

## 1 answers

### Answer by username_0 on 2019-03-28. Score: 0 | Accepted answer

The suggestion to order by sectionId resolved my issue here.

{% set entries = craft.entries().section('extendedEvents, festivalEvents'). orderBy({sectionId: SORT\_ASC}) %}

As it was, I was working with two sections, so my quick fix was to simply reverse the order of the output of the for loop...

{% for section, eventsInSection in allEventsBySection | reverse %}


---

