Backbone.js 如何对集合进行反向排序

Backbone.js 如何对集合进行反向排序,backbone.js,Backbone.js,以下集合将根据按升序创建的日期进行排序。如何按降序逆序排列 var MyCollection = Backbone.Collection.extend({ urlRoot: '/records', comparator: function(model) { return new Date(model.get('datecreated')).getTime(); } }); 从比较器返回负值 comparator: function(model) {

以下集合将根据按升序创建的日期进行排序。如何按降序逆序排列

var MyCollection = Backbone.Collection.extend({
    urlRoot: '/records',
    comparator: function(model) {
        return new Date(model.get('datecreated')).getTime();
    }
});

从比较器返回负值

comparator: function(model) {
  return -new Date(model.get('datecreated')).getTime();
}
看见