Answers.Body: <p>I've faced this a few times and solved it like this:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set entries = craft.entries.section([
      'section1',
      'section2',
      'section3',
  ]).all() %}
  
  {# group the results by section handle #}
  {% set entriesGrouped = entries|group('section.handle') %}
  
  {# use this array to specify a manual order to be used when outputting the results #}
  {% set manualSortOrder = [
      'section3',
      'section1',
      'section2',
   ] %}
  
  {# ================================== #}
  
  &lt;ul&gt;
      {% for sectionHandle in manualSortOrder %}
          {% if entriesGrouped[sectionHandle] is defined %}
              {% for entry in entriesGrouped[sectionHandle] %}
                  &lt;li&gt;&lt;a href=&quot;{{ entry.url }}&quot;&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
              {% endfor %}
          {% endif %}
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-06T10:59:46.390Z
Answers.Text: Thanks James. This is a nice approach.
Answers.UserDisplayName: Terry Upton
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-06T10:37:58.827Z
Answers.LastActivityDate: 2021-10-06T10:37:58.827Z
Answers.UserDisplayName: James Smith
Answers.Body: <p>Since posting the original question, I have also solved this like so:</p>
  <pre><code>{% set aboutPages = craft.entries.section(['about']).all() %}
  {% set newsPage = craft.entries.section('newsIndex').one() %}
  {% set aboutNavigation = aboutPages|merge([newsPage]) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-06T13:17:39.647Z
Answers.Text: Bear in mind that this approach will increase your query count, as you're making DB roundtrips every time you call .one() or .all().
Answers.UserDisplayName: James Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-06T10:58:11.763Z
Answers.LastActivityDate: 2021-10-06T10:58:11.763Z
Answers.UserDisplayName: Terry Upton
Body: <p>When getting pages from multiple sections like so:</p>
  <pre><code>  {% set aboutNavigation = craft.entries
      .section(['about', 'newsIndex'])
      .all() %}
  </code></pre>
  <p>How can I set order that the sections appear?
  So I want the <code>about</code> pages to be ordered first (by their structure order (which works out the box) and then the <code>newsIndex</code> page to be the last page in the order.</p>
  <p>How would this also apply if there were more than 2 sections in the array?</p>
  
Tags: <templating><ordering><order><elementquery>
Title: OrderBy section when selecting multiple sections in entries query
ThreadText: # OrderBy section when selecting multiple sections in entries query
  
  (Asked by: username_0 on 2021-10-06)
  
  When getting pages from multiple sections like so:
  
  ```
    {% set aboutNavigation = craft.entries
      .section(['about', 'newsIndex'])
      .all() %}
  
  ```
  
  How can I set order that the sections appear?
  So I want the `about` pages to be ordered first (by their structure order (which works out the box) and then the `newsIndex` page to be the last page in the order.
  
  How would this also apply if there were more than 2 sections in the array?
  
  **Tags:** templating, ordering, order, elementquery
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-10-06. Score: 2
  
  I've faced this a few times and solved it like this:
  
  ```twig
  {% set entries = craft.entries.section([
      'section1',
      'section2',
      'section3',
  ]).all() %}
  
  {# group the results by section handle #}
  {% set entriesGrouped = entries|group('section.handle') %}
  
  {# use this array to specify a manual order to be used when outputting the results #}
  {% set manualSortOrder = [
      'section3',
      'section1',
      'section2',
   ] %}
  
  {# ================================== #}
  
  <ul>
      {% for sectionHandle in manualSortOrder %}
          {% if entriesGrouped[sectionHandle] is defined %}
              {% for entry in entriesGrouped[sectionHandle] %}
                  <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
              {% endfor %}
          {% endif %}
      {% endfor %}
  </ul>
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks username_1. This is a nice approach.  
  
  ---
  
  ### Answer by username_0 on 2021-10-06. Score: 1
  
  Since posting the original question, I have also solved this like so:
  
  ```
  {% set aboutPages = craft.entries.section(['about']).all() %}
  {% set newsPage = craft.entries.section('newsIndex').one() %}
  {% set aboutNavigation = aboutPages|merge([newsPage]) %}
  
  ```
  
  > **Comments:**
  > **username_1**: Bear in mind that this approach will increase your query count, as you're making DB roundtrips every time you call .one() or .all().  
  
  ---
  
  