Insertion Sort Demo

const insertionSort = function (array) { for(let i = 1; i < array.length; i++) { const currentValue = array[i]; let j; for(j = i - 1; j >= 0; j--) { if(array[j] <= currentValue) break; array[j + 1] = array[j] } array[j + 1] = currentValue; } return array; }

9 3 6 1 2
NEXT