数组的翻转和排序

<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>

 

posted @ 2019-10-25 19:26  码上出彩  阅读(199)  评论(0编辑  收藏  举报