SOURCE

function selectSort(arr) {
    let i = 0;

    while(i < arr.length - 1) {
        let j = i;
        while(j < arr.length) {
            if (arr[j] < arr[i]) {
                [arr[i], arr[j]] = [arr[j], arr[i]];
               
            }
            j++
        }
        i++
    }
    return arr
}

console.log(selectSort([3, 9, 2, 1, 5, 7]))
console 命令行工具 X clear

                    
>
console