Skip to content

Instantly share code, notes, and snippets.

@mmuruev
Created March 6, 2017 10:01
Show Gist options
  • Save mmuruev/9f2c733f2be1ab01c9c179eeface8b98 to your computer and use it in GitHub Desktop.
Save mmuruev/9f2c733f2be1ab01c9c179eeface8b98 to your computer and use it in GitHub Desktop.
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