根据按升序创建的日期对集合进行排序。怎么能按降序逆序排序?
var MyCollection = Backbone.Collection.extend({
urlRoot: '/records',
comparator: function(model) {
return new Date(model.get('datecreated')).getTime();
}
});
答案 0 :(得分:1)
从比较器返回负值。
comparator: function(model) {
return -new Date(model.get('datecreated')).getTime();
}