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);
时间: 2024-11-10 15:25:09
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);