わかりました、Ember には Ember.ArrayProxy と Ember.SortableMixin があるので、次のようなことができます。
var sortedElements = Ember.ArrayProxy.createWithMixins(Ember.SortableMixin, {
content: yourElements.toArray(),
sortProperties: ['propertyYouWantToSortBy'],
sortAscending: false
});
他にも多くのオプションがあります。https://github.com/emberjs/ember.js/blob/master/packages/ember-runtime/lib/mixins/sortable.jsを参照してください。オーバーライドできる orderBy 関数:
orderBy: function(item1, item2) {
var result = 0,
sortProperties = get(this, 'sortProperties'),
sortAscending = get(this, 'sortAscending'),
sortFunction = get(this, 'sortFunction');
Ember.assert("you need to define `sortProperties`", !!sortProperties);
forEach(sortProperties, function(propertyName) {
if (result === 0) {
result = sortFunction(get(item1, propertyName), get(item2, propertyName));
if ((result !== 0) && !sortAscending) {
result = (-1) * result;
}
}
});
return result;
}
アサートを削除して、sorProperties を設定せずに、次のように変更することもできます。
orderBy: function(item1, item2) {
var result = 0,
sortAscending = get(this, 'sortAscending'),
sortFunction = get(this, 'sortFunction');
// implement your sort logic here, I don't know how you want to sort it
result = sortFunction(get(item1, propertyName), get(item2, propertyName));
return result;
}