<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>

CC BY-SA 3.0
2016-04-28T10:17:35.680Z
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
patrick.altair
CC BY-SA 3.0
2016-04-28T10:24:12.453Z
You can sort by multiple fields in asc/desc order using `.order( 'importance desc', 'postDate desc' )`
Luke Pearce
CC BY-SA 3.0
2016-04-28T09:46:24.740Z
2016-04-28T09:46:24.740Z
Luke Pearce
<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>

<entries>
How to loop through entries by importance?
# 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" %}

    
        
            {% if entry.logo | length %}
                {% for asset in entry.logo %}
                    
                {% endfor %}
            {% endif %}
        

        
            {{ entry.companyName }}
            {{ entry.description }}
        
    

    {% elseif entry.importance == "4" %}

        
            
                {% if entry.logo | length %}
                    {% for asset in entry.logo %}
                        
                    {% endfor %}
                {% endif %}
            

            
                {{ entry.companyName }}
                {{ entry.description }}
            
        

        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' )`  

---

