var ary = [8,9,10,3], compare = function(a,b){ return b.age-a.age; }, g = [ { name:"jim", age:29 }, { name:"tom", age:15 }, { name:"mary", age:20 } ]; g.sort(compare); console.log(g);