I have a hard time understanding how to use the array.sort() method to sort an array of objects based on a numeric value found in every object. Essentially I have a scenario of the following form:
var myarray = []
myarray.push({name: "alex", age: 8})
myarray.push({name: "ben", age: 57})
myarray.push({name: "dan", age: 32})
The initial order of the result would be "alex, ben, dan". Now I want to sort this array by age, so the oldest people are first on the list. After sorting the order should be "ben, dan, alex". How do I achieve this in the simplest way possible?