Created
December 7, 2013 02:29
-
-
Save premsh/7836591 to your computer and use it in GitHub Desktop.
sort javascript objects
This file contains 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
//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