Skip to content

Instantly share code, notes, and snippets.

@premsh
Created December 7, 2013 02:29
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 premsh/7836591 to your computer and use it in GitHub Desktop.
Save premsh/7836591 to your computer and use it in GitHub Desktop.
sort javascript objects
//This will sort your array
function SortByName(a, b){
var aName = a.name.toLowerCase();
var bName = b.name.toLowerCase();
return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
}
array.sort(SortByName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment