Answers.Body: <p>This should get you the desired results:</p>
  
  <pre><code>{% for entry in craft.entries.section('yoursection').order('startDate desc, featured desc') %}
  
      {# Entry Code #}
  
  {% endfor %}
  </code></pre>
  
  <p>If for any reason that doesn't achieve exactly what it is you are looking for, you could always break it up into multiple loops, 1 for featured, and 1 for not featured. It's not as clean as the above solution but should also solve the issue:</p>
  
  <p>This will use 2 loops, one for the featured and 1 for the not featured, assuming the 'featured' field is a lightswitch.</p>
  
  <pre><code>{% for entry in craft.entries.section('yoursection').search('featured:1').order('startDate desc') %}
  
      {# Entry Code #}
  
  {% endfor %}
  </code></pre>
  
  <p>and</p>
  
  <pre><code>{% for entry in craft.entries.section('yoursection').search('featured:not 1').order('startDate desc') %}
  
      {# Entry Code #}
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-04T06:03:11.947Z
Answers.LastActivityDate: 2016-10-04T06:29:07.740Z
Answers.LastEditDate: 2016-10-04T06:29:07.740Z
Answers.UserDisplayName: Christopher Healey
Body: <p>I want to put the index of section in order by two fields: <code>featured</code> and <code>startDate</code>. Basically, I want the <code>featured</code> entries to rise to the top of the index, and then within the featured posts I want them to be sorted by <code>startDate</code> field. Below the featured entries, I want the other entries to also be sorted by <code>startDate</code>.</p>
  
  <p>I tried <code>entries.order('featured desc').order('startDate desc')</code> but, as I expected, it simply ordered by <code>startDate</code> because that method executed after ordering by <code>featured</code>.</p>
  
  <p>Is there any way to achieve what I'm tring to do?</p>
  
Tags: <templating><search><ordering>
Title: How can I do nested ordering?
ThreadText: # How can I do nested ordering?
  
  (Asked by: username_0 on 2016-10-04)
  
  I want to put the index of section in order by two fields: `featured` and `startDate`. Basically, I want the `featured` entries to rise to the top of the index, and then within the featured posts I want them to be sorted by `startDate` field. Below the featured entries, I want the other entries to also be sorted by `startDate`.
  
  I tried `entries.order('featured desc').order('startDate desc')` but, as I expected, it simply ordered by `startDate` because that method executed after ordering by `featured`.
  
  Is there any way to achieve what I'm tring to do?
  
  **Tags:** templating, search, ordering
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-10-04. Score: 3 | Accepted answer
  
  This should get you the desired results:
  
  ```
  {% for entry in craft.entries.section('yoursection').order('startDate desc, featured desc') %}
  
      {# Entry Code #}
  
  {% endfor %}
  
  ```
  
  If for any reason that doesn't achieve exactly what it is you are looking for, you could always break it up into multiple loops, 1 for featured, and 1 for not featured. It's not as clean as the above solution but should also solve the issue:
  
  This will use 2 loops, one for the featured and 1 for the not featured, assuming the 'featured' field is a lightswitch.
  
  ```
  {% for entry in craft.entries.section('yoursection').search('featured:1').order('startDate desc') %}
  
      {# Entry Code #}
  
  {% endfor %}
  
  ```
  
  and
  
  ```
  {% for entry in craft.entries.section('yoursection').search('featured:not 1').order('startDate desc') %}
  
      {# Entry Code #}
  
  {% endfor %}
  
  ```
  
  
  ---
  
  