javascript sort array of objects by property


Posted on June 27, 2014
var employees=

[

{name:"George", age:32, retiredate:"March 12, 2014"},

{name:"Edward", age:17, retiredate:"June 2, 2023"},

{name:"Christine", age:58, retiredate:"December 20, 2036"},

{name:"Sarah", age:62, retiredate:"April 30, 2020"}

];



employees.sort(function(a, b){

 return a.age-b.age;

})



-- Lee