SOURCE

function test1 (array) {
    array = array.concat()
    let length = array.length
    let temp = array.length
    while(length > 0) {
        for (let j = 0; j < length; j++) {
            if (array[j] > array[j + 1]) {
                temp = j;
                [array[j], array[j + 1]] = [array[j + 1], array[j]];
            }
        }
        length = temp
    }
    return array
}

const array = [4, 7, 867, 65, 91, 6, 1, 100, 11]
console.log(test1(array))
console 命令行工具 X clear

                    
>
console