Help Sorting :(

This should be simpler in my mind, I’m fried as usual.
Creating a list of images like this:

{% set imgList =[] %}
{% for image in page.media.images %}
    {% set imgList = imgList|merge([image]) %}
{% endfor %}

Each image has an imagename.ext.meta.yaml file present such as this:

title: Mardis Gras Invitation
media: digital
intent: print
portfolio: true
description: Design for a benefit Mardi Gras party sponsoring The Human Race Theatre Company
date: 12/01/2015

I’d like to sort the imgList array by date, newest to oldest (descending?) when I’m outputting it like this:

<ul>
{% for img in imgList %} 
    <li>date: {{ img.meta.get('date') }} title: {{ img.meta.get('title') }}</li>
{% endfor %}
</ul>

Please advise.

I would do this:

  1. loop over image as you are doing, but insert them into an array with the key being the date.

  2. sort the array by key

  3. loop over the list again now in order by date.

Ohhh… fantastic idea, thank you!

@rhukster
I would do this:

  1. loop over image as you are doing, but insert them into an array with the key being the date.
  2. sort the array by key
  3. loop over the list again now in order by date.
    could you elaborate on this?
    i am trying to achieve the exact same thing, but you lost me at “insert them into an array with the key being the date” and “sort the array by key”…
    can i find this functionality documented somewhere?