好的,我有一个包含某个模型的对象的集合,这个模型包含一个日期和一个优先级,我希望它按日期排序,然后按优先级,我目前以这种方式实现:
App.Collections.Tasks = Backbone.Collection.extend({
model: App.Models.Task,
comparator: function(model)
{
return model.get("date") + model.get("priority");
}
});
这是我的输出:
Get to the party Edit Delete 1 Fri Feb 1
Get to the party Edit Delete 2 Mon Jan 28
Go to the store Edit Delete 4 Mon Jan 28
Go to the mall Edit Delete 3 Tue Jan 29
Get to the party Edit Delete 3 Tue Jan 29
Get to the party Edit Delete 5 Tue Jan 29
Get to the party Edit Delete 2 Wed Jan 30
Get to work Edit Delete 5 Wed Jan 30
我希望更早的日期始终排在首位,所以 2 月的日期应该是最后一个,我怎么能做到这一点?
谢谢!