寻找最小的数,然后放到遍历的位置
let arrSort = (arr) => {
let min;
for (let i = 0; i < arr.length; i++) {
min = arr[i]
for (let j = i + 1; j < arr.length; j++) {
if (arr[j] < min) {
[min, arr[j]] = [arr[j], min]
}
}
arr[i] = min
}
console.log(arr)
}
var arr = [1, 4, 2, 5, 7, 2, 5, 8, 3, 7, 3, 1, 4, 7, 92, 1, 5, 3, 6]
arrSort(arr)