lib/insertion-sort.js
function sort(array, compare) {
  for (var i = 1; i < array.length; i++) {
    var item = array[i];
    var indexHole = i;
    while (indexHole > 0 && compare(array[indexHole - 1], item) > 0) {
      array[indexHole] = array[--indexHole];
    }
    array[indexHole] = item;
    if (sortExternal.shiftObserver) {
      sortExternal.shiftObserver(i, indexHole);
    }
  }

  return array;
}
function sort(array, compare) {
  for (var i = 1; i < array.length; i++) {
    var item = array[i];
    var indexHole = i;
    while (indexHole > 0 && compare(array[indexHole - 1], item) > 0) {
      array[indexHole] = array[--indexHole];
    }
    array[indexHole] = item;
    if (sortExternal.shiftObserver) {
      sortExternal.shiftObserver(i, indexHole);
    }
  }

  return array;
}
function sort ( array , compare ) { for ( var i = 1 ; i < array . length ; i ++ ) { var item = array [ i ] ; var indexHole = i ; while ( indexHole > 0 && compare ( array [ indexHole - 1 ] , item ) > 0 ) { array [ indexHole ] = array [ -- indexHole ] ; } array [ indexHole ] = item ; if ( sortExternal . shiftObserver ) { sortExternal . shiftObserver ( i , indexHole ) ; } } return array ; }
Sorts an array using insertion sort.
@param {Array} array The array to sort.
@param {function} compare The compare function.
@returns The sorted array.
Sorts an array using insertion sort .