lib/quicksort.js
function partitionRandom(array, left, right, compare, swap) {
  var pivot = left + Math.floor(Math.random() * (right - left));
  if (pivot !== right) {
    swap(array, right, pivot);
  }
  return partitionRight(array, left, right, compare, swap);
}
function partitionRandom(array, left, right, compare, swap) {
  var pivot = left + Math.floor(Math.random() * (right - left));
  if (pivot !== right) {
    swap(array, right, pivot);
  }
  return partitionRight(array, left, right, compare, swap);
}
function partitionRandom ( array , left , right , compare , swap ) { var pivot = left + Math . floor ( Math . random ( ) * ( right - left ) ) ; if ( pivot !== right ) { swap ( array , right , pivot ) ; } return partitionRight ( array , left , right , compare , swap ) ; }
Partition the array by selecting a random pivot and 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.
Partition the array by selecting a random pivot and moving all elements less than the pivot to a lesser index and all elements greater than the pivot to a greater index .