SOURCE

function bubbleSort(arr) {
  const arrLength = arr.length;
  for(let i = 0; i < arrLength; i++) {
    for(let j = 0; j < arrLength - i - 1; j++) {
      if(arr[j] > arr[j+1]) {
        let temp = arr[j];
        arr[j] = arr[j+1];
        arr[j+1] = temp;
      }
    }
  }
  return arr;
}

const testArr = [5,3,4,7,0,9,1,6,2,8];
console.log(bubbleSort(testArr).join(','))
console 命令行工具 X clear

                    
>
console