I'm sorting a collection that is a computed property in my model:
collection: function() {
var entries = this.get('entries');
return entries.sortBy('prop1', 'prop2');
}.property('[email protected]', '[email protected]')
But I can't figure out how to get it to sort descending. That should be easy, right?
Ember 1.13
You can use Ember.computed.sort
macro: http://emberjs.com/api/classes/Ember.computed.html#method_sort
Example:
entriesSorting: ['prop1:desc', 'prop2:desc'],
collection: Ember.computed.sort('entries', 'entriesSorting')
Unrelated, but relevant: the usage of Ember.computed
over the .property
prototype extention is recommended.
UPDATE: Here is a twiddle of this working: https://ember-twiddle.com/19ff8c56f1c13512bdc8
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