In Ruby and Java you compare one object to another and return a number based on the order of those two objects. Backbone has support for sorting based solely on a single object.
This seems counter-initiative and more complex. Why does Backbone do this? Is there an advantage of using this technique?
From the docs:
This means that you can implement the
Comparatorin the classic way : a function with 2 parameters that behaves like the native javascriptsortfunction for arrays.Backbone just adds another way of sorting your collections that’s borrowed from underscore.