code: function partitionRight(array, left, right, compare, swap) {
    var mid = left;
  
    for (var i = mid; i < right; i++) {
      if (compare(array, i, right) <= 0) {
        if (i !== mid) {
          swap(array, i, mid);
        }
        mid++;
      }
    }
    if (right !== mid) {
      swap(array, right, mid);
    }
  
    return mid;
  }
docs: Partition the array using the right most element as the pivot by moving all
  elements less than the pivot to a lesser index and all elements greater than
  the pivot to a greater index.
  @param {Array} array The array to sort.
  @param {number} left The index to sort from.
  @param {number} right The index to sort to.
  @param {function} compare The compare function.
  @param {function} swapObserver A function to call when the swap operation is
  performed. This can be used to listen in on internals of the algorithm.
  @returns The pivot.