冒泡排序
作者:互联网
var arr = [4,2,1,3,5];
for (var i = 0; i <= arr.length - 1; i++) {
for (var j = 0; j <= arr.length - i - 1; j++) {
if(arr[j] > arr[j + 1]) {
var temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp
}
}
}
console.log(arr);
标签:arr,console,log,temp,冒泡排序,var 来源: https://www.cnblogs.com/llzh/p/16540773.html