code: function sort(array, compare, swap) {
    var pos = 1;
  
    while (pos < array.length) {
      if (compare(array, pos, pos - 1) >= 0) {
        pos++;
      } else {
        swap(array, pos, pos - 1);
        if (pos > 1) {
          pos--;
        }
      }
    }
  
    return array;
  }
docs: Sorts an array using gnome 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.