var array = [1,2,5,3]
//随机打乱数组
array.sort(function(ls, rs){
if(Math.random() < 0.5) {
return -1;
}
else {
return 1;
}
})
console.log(array);
//数组排序
var array1 = [1,2,5,3]
array1.sort(function(lhs, rhs){
if(lhs < rhs) {
return -1;
}
else {
return 1;
}
})
console.log(array1);