一、用sort()方法进行数组排序
var arr1 = [20, 80, 54, 78, 8, 67, 27];
function my(a,b){
return a-b;
}
console.log...(arr1.sort(my));//8,20,27,54,67,78,80
二、冒泡排序
var arr1 = [20, 80, 54, 78, 8, 67, 27];
function mys(arr1...}
};
};
return arr1;//返回到数组
};
console.log(mys(arr1));//8,20,27,54,67,78,80
三、选择排序