Created
March 6, 2017 10:01
-
-
Save mmuruev/9f2c733f2be1ab01c9c179eeface8b98 to your computer and use it in GitHub Desktop.
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
function compareAges(a,b) { | |
if (a.age < b.age) | |
return -1; | |
if (a.age > b.age) | |
return 1; | |
return 0; | |
} | |
let people = [{ name: 'John', age: '21' } , { name: 'Nick', age: 12 }, { name: 'Old' , age: 99 }]; | |
people.sort(compareAges); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment