var arr=[1,2,3,5,10,4,2,19,2,0];
alert(arr);//[1,2,3,5,10,4,2,19,2,0]
arr.sort(function (a, b) {//升序
return a-b;
});
alert(arr);//[0,1,2,2,3,4,5,10,19] var arr2=[{a:1},{a:4},{a:0}];
alert(arr2.map(function (value, index, array) {//[1,4,0]
return value.a;
}));
arr2.sort(function (a, b) {//降序
return b.a-a.a;
});
alert(arr2.map(function (value, index, array) {//[4,1,0]
return value.a;
}));