Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tracend
Created January 15, 2014 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tracend/8431016 to your computer and use it in GitHub Desktop.
Save tracend/8431016 to your computer and use it in GitHub Desktop.
_.sortByName() #underscore #mixin #cc
_.mixin({
// - Sort a list alphabetically
sortByName : function(a, b) {
var x = a.name.toLowerCase();
var y = b.name.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment