I need to sort a collection of Ember Models by multiple properties, and not necessary in the same direction/order. I.e. I need to sort by property a in ascending order and by property b in descending. Is there a way to achieve this?
I tried setting the sortAscending
property to a array, but it is not working.
After looking into the source it seems that this functionality is not supported out of the box(yet).
In your ArrayController:
sortProperties: ["propA:asc", "propB:desc"]
sortedModel: Ember.computed.sort("model", "sortProperties");
Then reference sortedModel
in your template's #each
handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With