Last active
April 18, 2018 05:25
-
-
Save BuildWithLal/2c4c7390c631ab22e31fca3e82cae10d 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
function sortByAge(a,b) { | |
if (a.age < b.age) | |
return -1; | |
if (a.age > b.age) | |
return 1; | |
return 0; | |
} | |
students = [{name: 'Axen', age: 12}, {name: 'Mike', age:10}, {name: 'John', age: 11}]; | |
students.sort(sortByAge); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment