js 整数排序
时间:2021-08-21 10:28:31
收藏:0
阅读:7
function com(value1, value2) {
if (value1 < value2) {
return -1;
} else if (value1 > value2) {
return 1;
} else {
return 0;
}
}
var box = [1, 2, 3, 4, 5, 15, 22, 55];
alert(typeof(box));
alert(box.sort(com));
alert(box.reverse());
alert(typeof(box));
原文:https://www.cnblogs.com/tiandlsd001/p/15168939.html
评论(0)