JS排序,sort,bubble,select,insert
web前端-js教程
最近开始学习数据结构。o2o商城预约系统源码,ubuntu系统重启服务,爬虫教程犯法吗,短信 php,苏州seo干货lzw
一点一点整理,希望能坚持下来。房屋出租管理系统源码下载,安装ubuntu会卡住,tomcat大数据量返回,爬虫工作日常,php开发教程零基础交流,seo免费培lzw
因为方向是前端,所以用JavaScript实现。网易云音乐 web 源码,vm ubuntu16,tomcat日访问量,爬虫数据代码,php json面试题,seo 厦门lzw
//sort排序var testArr1=[3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48];var testArr2=[3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48];var testArr3=[3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48];testArr1.sort();//排序结果:[15, 19, 2, 26, 27, 3, 36, 38, 4, 44, 46, 47, 48, 5, 50]testArr2.sort(function(a,b){return a>b});//排序结果:[2, 3, 4, 5, 15, 19, 26, 27, 36, 38, 44, 46, 47, 48, 50]testArr3.sort(function(a,b){return a-b});//排序结果:[2, 3, 4, 5, 15, 19, 26, 27, 36, 38, 44, 46, 47, 48, 50]//Bubble排序
var testArr1=[3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48];var testArr2=[3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48];function bubbleSort1(array){ for(i=array.length-1;i>0;i--){ for(j=0;j<i;j++){ if(array[j+1]0;i--){ for(j=0;j<i;j++){ if((array[j+1]-array[j])<0){ var temp=array[j+1]; array[j+1]=array[j]; array[j]=temp; } } }}bubbleSort1(testArr1);//排序结果:[2,3,4,5,15,19,26,27,36,38,44,46,47,48,50]bubbleSort2(testArr2);//排序结果:[2,3,4,5,15,19,26,27,36,38,44,46,47,48,50]//Select排序
var testArr=[3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48];//Insert排序
function selectSort(array){
for(i=0;i
var testArr=[3, 44, 38, 5, 47, 15, 36, 26, 27, 2, 46, 4, 19, 50, 48];
function insertSort(array){
for (var i = 0 ; i = 0; j--) {
if(curElement