Created
May 1, 2011 04:10
-
-
Save andrewdeandrade/950240 to your computer and use it in GitHub Desktop.
Reverse Alphabetical Sort in Backbone.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assumption: You have a model with a name. | |
comparator: function (User) { | |
if (User.get("name")) { | |
var str = User.get("name"); | |
str = str.toLowerCase(); | |
str = str.split(""); | |
str = _.map(str, function(letter) { return String.fromCharCode(-(letter.charCodeAt(0))) }); | |
return str; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My production example using @bryancallahan's suggestion: