sort()
来源:互联网 发布:2000到2008年网络歌曲 编辑:程序博客网 时间:2024/05/21 11:32
sort():(The function will change the original array)
1.
<script> var arr = [1,3,2,5,4]; console.log(arr.sort()); //[1,2,3,4,5] console.log(arr); //[1,2,3,4,5]</script>
2.
<script> var arr = [1,3,2,5,4]; console.log(arr.sort(function(a,b){return a-b;})); //[1,2,3,4,5] console.log(arr.sort(function(a,b){return b-a;})); //[5,4,3,2,1]</script>
3.items appear at random
<script> var arr = [1,3,2,5,4]; console.log(arr.sort(function(){return Math.random()-0.5})); //[1, 3, 5, 4, 2]、[3, 4, 5, 2, 1]...</script>
0 0
- sort
- Sort
- sort
- Sort
- sort
- Sort
- sort
- sort
- Sort
- Sort
- sort
- sort
- sort
- sort()
- sort
- sort
- sort
- sort
- c++ socket 10022 listen监听失败 BUG!
- samtools命令解析
- OJ.字符串多级排序
- 简单JavaScript模版引擎优化
- setOnItemClickListener失效
- sort()
- java Script 组合模式 简单实例
- 办公/ntfs格式/mplayer/yum提示副本
- mysql使用REPLACE替换字段里数据内容部分字符串
- SpringMVC返回json数据(@ResponseBody注解的使用)
- OJ.具有下列性质的数
- OJ.俄式乘法
- mongodb数据库启动和停止
- 关于cordova混合型app使用input file注意事项