SOURCE

const arr = [3,5,4,2,6,5,9,1];

const func = ()=>{
    for(let i = 0; i < arr.length-1 ; i++){
        for(let j = i + 1 ; j < arr.length  ; j++){
            if(arr[i] > arr[j]){
                [arr[i],arr[j]] = [arr[j],arr[i]];
            }
        }
    }
}
func();
console.log(arr);

console 命令行工具 X clear

                    
>
console