insertion sort
function insertSort(arr) {
for (let i = 0; i < arr.length; i++) {
console.log(...arr);
console.log(' '.repeat(i) + '^|');
for (let j = i; j > 0;) {
if (arr[j] >= arr[j - 1]) {
break;
}
[arr[j], arr[j - 1]] = [arr[j - 1], arr[j]];
j--;
console.log(...arr);
console.log(' '.repeat(j) + '^' + ' '.repeat(i - j) + '|');
}
}
}
insertSort([1, 3, 2, 5, 4, 8, 9, 7, 6, 0]);
INFO