I have a Ember.ArrayController
that has an unsorted content.
I want to know if its possible to sort the content of an ArrayController without using a new property.
I could of course create a new property:
App.MyArrayController = Em.ArrayController.extend({
mySortMethod: function(obj1, obj2) {
// some code here
},
updateSortedContent: function() {
var content = this.get('content');
if (content) {
var sortedContent = content.copy();
sortedContent.sort(this.mySortMethod);
this.set('sortedContent', sortedContent);
}
}.observes('content')
});
But I hope there is a better way that does not duplicates the content.
See Question&Answers more detail:os