关键在于arr.sort()方法
//升序
function sortBy(propertyName) {
return function(obj1,obj2) {
var val1 = obj1.propertyName;
var val2 = obj2.propertyName;
return val1 - val2;
}
}
var data = [{name: "Zachary"age: 28}{name: "Nicholas"age: 29}];
data.sort(sortBy('age'));