documentcloud/backbone — pull request #1342 by caseywebdev (2012-05-23 16:03:22+00:00)
Title: Allow Collection to receive falsy `comparator` to override default

The alternative to this is something like

```coffeescript
new Collection models, comparator: ->
```

but that seems a little dirty to me as I don't want to sort it differently or with a 'fake' sort function, but rather not sort it all like a vanilla Backbone.Collection would do. This allows me to pass in

```coffeescript
new Collection models, comparator: false # or null or '' or 0
```

to return the collection to 'no sort' mode. I came across this while implementing a search. Every other time I want this collection to sort by a name.

```coffeescript
class Collection extends Backbone.Collection
comparator: (model) -> model.get 'name'
```

But, the order of items initialized in the collection from the search is specific to the query function. When I do

```coffeescript
new Collection searchResults, comparator: false
```

I can keep my order.