Solution for "js sort array of arrays objects by value"

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

javascript sort array with objects

var names = ["Peter", "Emma", "Jack", "Mia", "Eric"]; names.sort(); // ["Emma", "Eric", "Jack", "Mia", "Peter"] var objs = [ {name: "Peter", age: 35}, {name: "Emma", age: 21}, {name: "Jack", age: 53} ]; objs.sort(function(a, b) { return a.age - b.age; }); // Sort by age (lowest first)

javascript sort

Similar codes for "js sort array of arrays objects by value"


Latest 'Javascript' questions

Added before "js sort array of arrays objects by value"