Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Last active August 29, 2015 14:20
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 juliandescottes/d04ceceb03fbbe0164a3 to your computer and use it in GitHub Desktop.
Save juliandescottes/d04ceceb03fbbe0164a3 to your computer and use it in GitHub Desktop.
Sort on string keys
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