Skip to content

Instantly share code, notes, and snippets.

@Amitesh
Created December 5, 2016 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Amitesh/a6cea576f38fda8111d19fb0c22f26bc to your computer and use it in GitHub Desktop.
Save Amitesh/a6cea576f38fda8111d19fb0c22f26bc to your computer and use it in GitHub Desktop.
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