Sorting strings in reverse order with backbone.js

后端 未结 6 2005
南方客
南方客 2020-12-08 07:25

I\'m trying to sort a Backbone.js collection in reverse order. There are previous replies on how to do this with integers, but none with strings.

var Chapter         


        
6条回答
  •  失恋的感觉
    2020-12-08 07:42

    Just add minus before chapter.get

    chapters.comparator = function(chapter) {
        return -chapter.get("title");
    };      
    

提交回复
热议问题