Skip to content

Instantly share code, notes, and snippets.

@blackboxx
Created April 27, 2017 10:24
Show Gist options
  • Save blackboxx/7805644991e7ff75cb973c41e689e7e8 to your computer and use it in GitHub Desktop.
Save blackboxx/7805644991e7ff75cb973c41e689e7e8 to your computer and use it in GitHub Desktop.
var people=[{name:'Alex',age:12},{name:'Eva',age:11}]
function compare(a,b) {
if (a.age < b.age)
return -1;
if (a.age > b.age)
return 1;
return 0;
}
people.sort(compare);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment