lib/array/sort.js
function insertionSort(a, l, h, c) {
  for (let i = l + 1; i <= h; i++) {
    const x = a[i];
    let j = i - 1;

    while (j >= 0 && c(a[j], x) > 0) {
      a[j + 1] = a[j];
      j--;
    }

    a[j + 1] = x;
  }
}
function insertionSort(a, l, h, c) {
  for (let i = l + 1; i <= h; i++) {
    const x = a[i];
    let j = i - 1;

    while (j >= 0 && c(a[j], x) > 0) {
      a[j + 1] = a[j];
      j--;
    }

    a[j + 1] = x;
  }
}
Insertion sort an array.

@see https://en.wikipedia.org/wiki/Insertion_sort

@param {Array} a The array to insertion sort.
@param {number} l The lower index of the sorting.
@param {number} h The higher index of the sorting.
@param {Function} c The comparator to use.
@private