Format for sort order on Ember.Array.sortBy


I am trying to sort an array of Models with Array.sortBy() in descending order.

An example would be model.get('hasManyRelationship').sortBy('createdAt') Created at is an iso 8601 dateTIme

How can I control whether the out put of sortBy will be ascending or desceding? I tried sortBy.('createdAt:asc') but no luck.


I think Ember.SortableMixin can still be used to overwrite your iso 8601 dateTime compare if necessary like this:


I saw your stackoverflow question and provided an answer there. I’m just cross linking it here incase anyone has the same question.

Here is a twiddle I built that helps demonstrate your question on SO:

Certainly there are other ways to do this, that’s just my take.

Also, FWIW, SortableMixin has been removed from Ember 2.x. Even though it’s available in the controller addon, it’ll likely become unsupported at some point in the near future.