Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sort Array of objects
/**
* Sort an array of object.
*/
var sample = [
{ name: 'Ram', age: 21 },
{ name: 'Shyam', age: 37 },
{ name: 'Gyan', age: 45 }
];
sample.sort(function(a,b) {
return a.age - b.age;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.