js数组排序

var arr = [1,5,3,2];
arr.sort(
 function (a,b){
    return a-b //升序
    return b-a //降序          
}       
)
var points = [40, 100, 1, 5, 25, 10];
points.sort(function(a, b){return 0.5 - Math.random()}); //以随机顺序排序数组
 

 


原文地址:https://www.cnblogs.com/punisher999/p/12296601.html