작성
·
180
0
function solution(arr: Array<number>): Array<number> {
let cacheIdx: number = 0;
for (let i: number = 0; i < arr.length - 1 - cacheIdx; i++) {
for (let j: number = 0 + cacheIdx; j < arr.length - 1; j++) {
if (0 < arr[j]) [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
else cacheIdx++;
}
}
return arr;
}