jashkenas/backbone — pull request #2706 by akre54 (2013-08-02 06:02:26+00:00)
Title: Update comparator example

Promote the shorter string form of Collection#comparator for simple attribute sorting (really just sugar for the current form given in the example).

It might also be helpful to include an example of a comparator function, if not in the docs (for the interest of space) then maybe in some one-liners page on the wiki.

```javascript
var deck = new Backbone.Collection;
deck.comparator = function() {
return _.random(0, this.length);
};
_(52).times(function(n) {
deck.add({id: n, suit: Math.ceil(n / 12), value: n % 13});
});

alert(JSON.stringify(deck.first()));
```