Reverse sort order with Backbone.js

前端 未结 15 980
不知归路
不知归路 2020-12-02 05:45

With Backbone.js I\'ve got a collection set up with a comparator function. It\'s nicely sorting the models, but I\'d like to reverse the order.

How can I sort the m

15条回答
  •  猫巷女王i
    2020-12-02 06:13

    Here's a quick and easy way to reverse-sort a collection's models using UnderscoreJS

     var reverseCollection = _.sortBy(this.models, function(model) {
       return self.indexOf(model) * -1;
     });

提交回复
热议问题