function partition(array, low, high) {
  const pivotIndex = low; // <1>
  let pivotFinalIndex = pivotIndex; // <2>

  for (let current = pivotIndex + 1; current <= high; current++) {
    if (array[current] < array[pivotIndex]) { // <3>
      pivotFinalIndex += 1; // <4>
      swap(array, current, pivotFinalIndex); // <5>
    }
  }

  swap(array, pivotIndex, pivotFinalIndex); // <6>
  return pivotFinalIndex;
}
Linear-time Partitioning
Chooses a pivot and re-arrage the array that
 everything on the left is <= pivot and
 everything on the right is > pivot

Runtime: O(n)
@param {*} array
@param {*} low start index
@param {*} high end index
@returns {integer} pivot index