lib/comb-sort.js
function sort(array, compare, swap) {
  var gap = array.length;
  var shrinkFactor = 1.3;
  var swapped;

  while (gap > 1 || swapped) {
    if (gap > 1) {
      gap = Math.floor(gap / shrinkFactor);
    }

    swapped = false;

    for (var i = 0; gap + i < array.length; ++i) {
      if (compare(array, i, i + gap) > 0) {
        swap(array, i, i + gap);
        swapped = true;
      }
    }
  }

  return array;
}
function sort(array, compare, swap) {
  var gap = array.length;
  var shrinkFactor = 1.3;
  var swapped;

  while (gap > 1 || swapped) {
    if (gap > 1) {
      gap = Math.floor(gap / shrinkFactor);
    }

    swapped = false;

    for (var i = 0; gap + i < array.length; ++i) {
      if (compare(array, i, i + gap) > 0) {
        swap(array, i, i + gap);
        swapped = true;
      }
    }
  }

  return array;
}
function sort ( array , compare , swap ) { var gap = array . length ; var shrinkFactor = 1.3 ; var swapped ; while ( gap > 1 || swapped ) { if ( gap > 1 ) { gap = Math . floor ( gap / shrinkFactor ) ; } swapped = false ; for ( var i = 0 ; gap + i < array . length ; ++ i ) { if ( compare ( array , i , i + gap ) > 0 ) { swap ( array , i , i + gap ) ; swapped = true ; } } } return array ; }
Sorts an array using comb sort.
@param {Array} array The array to sort.
@param {function} compare The compare function.
@param {function} swap A function to call when the swap operation is
performed. This can be used to listen in on internals of the algorithm.
@returns The sorted array.
Sorts an array using comb sort .