数组的翻转和排序

Posted my12-28

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数组的翻转和排序相关的知识,希望对你有一定的参考价值。

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

 

以上是关于数组的翻转和排序的主要内容,如果未能解决你的问题,请参考以下文章