Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sort array of objects javascript

//sort array of objects javascript

var array = [
  {name: "John", age: 34},
  {name: "Peter", age: 54},
  {name: "Jake", age: 25}
];

array.sort(function(a, b) {
  return a.age - b.age;
}); // Sort youngest first
Source by flaviocopes.com #
 
PREVIOUS NEXT
Tagged: #sort #array #objects #javascript
ADD COMMENT
Topic
Name
7+6 =