We had a lot of pain sorting our collections, since they are not there when the page is opened you need to continually re-sort…
App.Controller.Events = Ember.ArrayController.extend({
init: function() {
this._super();
Helper.assignSortedCollection(this, 'content', Oceans.store.findAll(Oceans.Model.Event), function(item){
return -1 * item.get('created_at').getTime();
});
}
});
Helper = {
assignSortedCollection: function(to, path, items, sorter){
items.addObserver('length', function(){
var temp = Ember.A();
this.forEach(function(item) { temp.pushObject(item); });
to.set(path, _(temp).sortBy(sorter));
});
}
}