Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
function insertionSort(array) {
  for (let i = 0; i < array.length; i++) {
    let j = i - 1
    while (j >= 0 && array[j] > array[i]) {
      array[j + 1] = 
    }
  }
}

insertionSort([9, 5, 10, 8, 2]) // [2, 5, 8, 9, 10]
node v10.15.2 linux/amd64