SOURCE

let testArr = [5, 17, 1, 33, 6, 20];
document.write(testArr + "<br/>");

function selectionSort(arr) {
    let temp;
    for (let i = 0; i < arr.length; i++) {
        for (let j = i; j < arr.length; j++) {
            if (arr[j] < arr[i]) {
                temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
    }
    return arr;
}

document.write(selectionSort(testArr));
console 命令行工具 X clear

                    
>
console