//冒泡排序 function bubble(arr){ for(var j=0;j<arr.length-1;j++) { for(var i=0;i<arr.length-1;i++) { if(arr[i]>arr[i+1]) { temp=arr[i+1] arr[i+1]=arr[i] arr[i]=temp } } } return arr } var number=[10,20,5,0,7,6] console.log("number:"+number) console.log("bubble:"+bubble(number))