Answers.Body: <p>Yes, you can use <code>.order</code> with any custom field, an example is below.</p>
  
  <p><code>craft.entries.section( 'sectionHandle' ).order( 'customFieldHandle' )</code></p>
  
  <p>For more info see the docs
  <a href="https://craftcms.com/docs/templating/craft.entries#order" rel="nofollow">https://craftcms.com/docs/templating/craft.entries#order</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-28T10:17:35.680Z
Answers.Text: I've tried .order('importance') but that shows the order from 1-5. So I tried .order('importance desc') which does show from 5-1 but also reverses the order showing the oldest entries first which I don't want. Is there a way to have 5-1 and newest first? Thanks
Answers.UserDisplayName: patrick.altair
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-28T10:24:12.453Z
Answers.Text: You can sort by multiple fields in asc/desc order using `.order( 'importance desc', 'postDate desc' )`
Answers.UserDisplayName: Luke Pearce
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-28T09:46:24.740Z
Answers.LastActivityDate: 2016-04-28T09:46:24.740Z
Answers.UserDisplayName: Luke Pearce
Body: <p>I have a channel of entries I'd like to loop through by order of importance on a scale of 1-5 with 5 being the most important and appearing first.</p>
  
  <p>I tried to achieve this using a radio button field called importance and if else statements like:</p>
  
  <pre><code>{# List most important entries first #}
  {% if entry.importance == "5" %}
  
      &lt;li class="deal"&gt;
          &lt;div class="brand-image-wrapper"&gt;
              {% if entry.logo | length %}
                  {% for asset in entry.logo %}
                      &lt;img class="grayscale" src="{{ asset.url }}" alt="{{ image.title }}"&gt;
                  {% endfor %}
              {% endif %}
          &lt;/div&gt;
  
          &lt;div class="info"&gt;
              &lt;h2 class="title"&gt;{{ entry.companyName }}&lt;/h2&gt;
              &lt;p&gt;{{ entry.description }}&lt;/p&gt;
          &lt;/div&gt;
      &lt;/li&gt;
  
      {% elseif entry.importance == "4" %}
  
          &lt;li class="deal"&gt;
              &lt;div class="brand-image-wrapper"&gt;
                  {% if entry.logo | length %}
                      {% for asset in entry.logo %}
                          &lt;img class="grayscale" src="{{ asset.url }}" alt="{{ image.title }}"&gt;
                      {% endfor %}
                  {% endif %}
              &lt;/div&gt;
  
              &lt;div class="info"&gt;
                  &lt;h2 class="title"&gt;{{ entry.companyName }}&lt;/h2&gt;
                  &lt;p&gt;{{ entry.description }}&lt;/p&gt;
              &lt;/div&gt;
          &lt;/li&gt;
  
          etc...
  </code></pre>
  
  <p>But this isn't very DRY and this lists the entries but they are still ordered by date. Is it possible to use .order with a field to achieve this?</p>
  
Tags: <entries>
Title: How to loop through entries by importance?
ThreadText: # How to loop through entries by importance?
  
  (Asked by: username_0 on 2016-04-28)
  
  I have a channel of entries I'd like to loop through by order of importance on a scale of 1-5 with 5 being the most important and appearing first.
  
  I tried to achieve this using a radio button field called importance and if else statements like:
  
  ```
  {# List most important entries first #}
  {% if entry.importance == "5" %}
  
      <li class="deal">
          <div class="brand-image-wrapper">
              {% if entry.logo | length %}
                  {% for asset in entry.logo %}
                      <img class="grayscale" src="{{ asset.url }}" alt="{{ image.title }}">
                  {% endfor %}
              {% endif %}
          </div>
  
          <div class="info">
              <h2 class="title">{{ entry.companyName }}</h2>
              <p>{{ entry.description }}</p>
          </div>
      </li>
  
      {% elseif entry.importance == "4" %}
  
          <li class="deal">
              <div class="brand-image-wrapper">
                  {% if entry.logo | length %}
                      {% for asset in entry.logo %}
                          <img class="grayscale" src="{{ asset.url }}" alt="{{ image.title }}">
                      {% endfor %}
                  {% endif %}
              </div>
  
              <div class="info">
                  <h2 class="title">{{ entry.companyName }}</h2>
                  <p>{{ entry.description }}</p>
              </div>
          </li>
  
          etc...
  
  ```
  
  But this isn't very DRY and this lists the entries but they are still ordered by date. Is it possible to use .order with a field to achieve this?
  
  **Tags:** entries
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-28. Score: 4 | Accepted answer
  
  Yes, you can use `.order` with any custom field, an example is below.
  
  `craft.entries.section( 'sectionHandle' ).order( 'customFieldHandle' )`
  
  For more info see the docs
  <https://craftcms.com/docs/templating/craft.entries#order>
  
  > **Comments:**
  > **username_0**: I've tried .order('importance') but that shows the order from 1-5. So I tried .order('importance desc') which does show from 5-1 but also reverses the order showing the oldest entries first which I don't want. Is there a way to have 5-1 and newest first? Thanks  
  > **username_1**: You can sort by multiple fields in asc/desc order using `.order( 'importance desc', 'postDate desc' )`  
  
  ---
  
  