Created
April 27, 2017 10:24
-
-
Save blackboxx/7805644991e7ff75cb973c41e689e7e8 to your computer and use it in GitHub Desktop.
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:'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