Sort the number of numbers in the array from smallest to largest. It is not possible to assign a value directly

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; }}