window.onload = () => { //冒泡排序 function bubbleSort(arr) { for(let i=0; i<arr.length-1; i++){ for(let j=i+1; j<arr.length; j++){ if(arr[i]>arr[j]){ let temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } return arr; } let myArr = [3,4,5,6,3,2,1,0,8,4,2,3]; console.log(bubbleSort(myArr)) }