sort排序
1.
var names=['Xand','Jack','Brand','Artist'];
names.sort();
返回:
["Artist", "Brand", "Jack", "Xand"]
2.
var nums=[43,12,446,874,33];
nums.sort(function(a,b){
return a-b;
});
或者
nums.sort((a,b) => a-b);
返回:
[12, 33, 43, 446, 874]