长度为 N 的数组记录中 1 - N 个数字
将数组中的数从小到大排序
不能够间接赋值
let arr = [1, 6, 3, 2, 9, 10, 11, 4, 7, 5, 12, 8];
let i = 0, temp = 0;
while(temp++ < arr.length) {if (arr[i] === i + 1) {i ++} else {const temp = arr[arr[i] - 1];
arr[arr[i] - 1] = arr[i];
arr[i] = temp;
}
}