数组的翻转和排序

<script>
//数组排序:sort(功能很强大!能对数字和字母进行排列。
    //    回调函数。
    console.log(arr2.sort(function (a,b) {
//                a-b升序
//                b-a降序
            return a-b;
    }));

var arr2 = [7,6,15,4,13,2,1];
console.log(arr2.sort(function(){
    return a-b;
}));    
</script>

猜你喜欢

转载自www.cnblogs.com/my12-28/p/11739907.html