javascript - Backbone: reverse string comparator -


backbone has nifty little comparator feature takes attribute name string , sorts it. need sort in descending order.

var chapter  = backbone.model; var chapters = new backbone.collection;  chapters.comparator = 'title' // sorts title, ascending  chapters.add(new chapter({page: 9, title: "the end"})); chapters.add(new chapter({page: 5, title: "the middle"})); chapters.add(new chapter({page: 1, title: "the beginning"}));  console.log(chapters.pluck('title')); 

is there way without introducing comparator function?

well, specifying .comparator delegates _.sortby docs specify calls _.property. no, can pass function (a _.pluck - between arguments in reverse order) suspect know this.


Comments

Popular posts from this blog

html - height not adding height to a empty div -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

python - Robot Framework location and name of keyword -