documentcloud/backbone — pull request #1968 by taka84u9 (2012-12-18 15:18:17+00:00)
Title: string comparator starts with '-' means descending order

Developers have to use `sortBy` -style or `sort` -style comparator function to sort collection in descending order. This PR allows comparator string start with '-' to easily achieve the purpose.

```js
var collection = new Backbone.Collection([
{id: 3},
{id: 1},
{id: 2}
], {comparator: '-id'});
collection.pluck('id'); // => [3, 2, 1]
```

Note that backward compatibility is broken a bit: attributes start with '-' needs backslash escaping, but I think such kind of names are really rare.

```js
var collection = new Backbone.Collection([
{'-id': 3},
{'-id': 1},
{'-id': 2}
], {comparator: '\\-id'});
collection.pluck('-id'); // => [1, 2, 3]
```