<p>You're so close it's maddening—you should be able to order by a custom field as well:</p>

<pre><code>{% set assets = craft.assets.find({sourceId: 2, order: 'date desc'}) %}
</code></pre>

<p>Where <code>date</code> is the name of your custom field.</p>

<p>From the <a href="http://buildwithcraft.com/docs/templating/craft.assets#order">Craft docs</a> (emphasis added):</p>

<blockquote>
  <p>Possible values include 'title', 'id', 'sourceId', 'folderId', 'filename', 'kind', 'width', 'height', 'size', 'dateCreated', and 'dateUpdated', <strong>as well as any textual custom field handles</strong>.</p>
</blockquote>

CC BY-SA 3.0
2014-07-14T17:44:45.780Z
Thank you. I was so close. It works perfectly. I've also noted your edits on my post for future questions.
Niall Thompson
CC BY-SA 3.0
2014-07-14T17:46:32.213Z
@NiallThompson Your question was excellent and thorough, I just did some tidying. I hope you don't mind :)
Matt Stein
CC BY-SA 3.0
2014-07-14T17:31:17.083Z
2014-07-14T17:37:22.663Z
2014-07-14T17:37:22.663Z
Matt Stein
<p>I have a page which lists assets by source. I've added a date field to the asset.</p>

<p>How can I order the assets by this field so that the most recent is first?</p>

<p><img src="https://i.sstatic.net/doYWd.png" alt="asset date field"></p>

<p>Here is my markup:</p>

<pre><code>{% set assets = craft.assets.find({sourceId: 2}) %}

{% for asset in assets %}
    &lt;a href="{{ asset.url }}"&gt;{{ asset.date | date('M Y') }}&lt;/a&gt;
{% endfor %}
</code></pre>

<p>Looking at the <a href="http://straightupcraft.com/cheat-sheets" rel="nofollow noreferrer">cheat sheet for Assets</a> it seems that these are my only options for order:      <code>title</code>, <code>id</code>, <code>sourceId</code>, <code>folderId</code>, <code>filename</code>, <code>kind</code>, <code>width</code>, <code>height</code>, <code>size desc</code>'.</p>

<p>Ideally I could do something like this:</p>

<pre><code>{% set assets = craft.assets.find({sourceId: 2, order: '{{ asset.date }}'}) %}
</code></pre>

<assets><date><ordering>
Order Assets by date field
# Order Assets by date field

(Asked by: username_0 on 2014-07-14)

I have a page which lists assets by source. I've added a date field to the asset.
How can I order the assets by this field so that the most recent is first?

Here is my markup:
{% set assets = craft.assets.find({sourceId: 2}) %}

{% for asset in assets %}
    {{ asset.date | date('M Y') }}
{% endfor %}

Looking at the cheat sheet for Assets it seems that these are my only options for order:      title, id, sourceId, folderId, filename, kind, width, height, size desc'.
Ideally I could do something like this:
{% set assets = craft.assets.find({sourceId: 2, order: '{{ asset.date }}'}) %}

**Tags:** assets, date, ordering

---

## 1 answers

### Answer by username_1 on 2014-07-14. Score: 7 | Accepted answer

You're so close it's maddening—you should be able to order by a custom field as well:
{% set assets = craft.assets.find({sourceId: 2, order: 'date desc'}) %}

Where date is the name of your custom field.
From the Craft docs (emphasis added):

Possible values include 'title', 'id', 'sourceId', 'folderId', 'filename', 'kind', 'width', 'height', 'size', 'dateCreated', and 'dateUpdated', as well as any textual custom field handles.

> **Comments:**
> **username_0**: Thank you. I was so close. It works perfectly. I've also noted your edits on my post for future questions.  
> **username_1**: @NiallThompson Your question was excellent and thorough, I just did some tidying. I hope you don't mind :)  

---

