Last active
April 26, 2024 23:04
-
-
Save juliandescottes/d04ceceb03fbbe0164a3 to your computer and use it in GitHub Desktop.
Sort on string keys
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
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