You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One thing I'd like to do is perform sorts using a compareFunction comparator callback similar to how Array.prototype.sort does it. The callback provides two models as arguments (a and b), and the result of the function is whether A is greater than B, vice-vera, or they're equal. This allows you to do much more complex sorts that are multi-layered and don't have to rely on string comparison.
The following issue calls out this issue as it originally appeared in Backbone. The ability to provide a compareFunction-like sort comparator has since been added.
Should be possible, and would be a good feature. The relevant code in backbone is here. Note that it switches by testing the number of arguments that the function accepts using Function#length, which we'd want to copy. The code you'd want to modify is in backbone-sorted-collectionhere.
I'm afraid I don't really have free cycles to work on this at the moment, but I'm happy to review / merge PRs or walk you through code :) Let me know if you want to be added as a collaborator.
@jmorrell Great work on this library!
One thing I'd like to do is perform sorts using a compareFunction comparator callback similar to how Array.prototype.sort does it. The callback provides two models as arguments (a and b), and the result of the function is whether A is greater than B, vice-vera, or they're equal. This allows you to do much more complex sorts that are multi-layered and don't have to rely on string comparison.
The following issue calls out this issue as it originally appeared in Backbone. The ability to provide a compareFunction-like sort comparator has since been added.
jashkenas/backbone#488
Would this be difficult to add? I might look into doing it if I get some time soon.
The text was updated successfully, but these errors were encountered: