Last active
August 29, 2015 14:20
-
-
Save juliandescottes/d04ceceb03fbbe0164a3 to your computer and use it in GitHub Desktop.
Sort on string keys
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
var people = [ | |
{name : "Zoe", age : 20}, | |
{name : "Alicia", age : 18}, | |
{name : "John", age : 22} | |
]; | |
people.sort(function (p1, p2) { | |
return p1.name.localeCompare(p2.name); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment