lib/array/sort.js
function pivot(a, l, h, c) {
  const p = (l + ((h - l) / 2)) | 0;

  if (c(a[h], a[l]) < 0) {
    [a[l], a[h]] = [a[h], a[l]];
  }

  if (c(a[p], a[l]) < 0) {
    [a[l], a[p]] = [a[p], a[l]];
  }

  if (c(a[h], a[p]) < 0) {
    [a[h], a[p]] = [a[p], a[h]];
  }

  return p;
}
function pivot(a, l, h, c) {
  const p = (l + ((h - l) / 2)) | 0;

  if (c(a[h], a[l]) < 0) {
    [a[l], a[h]] = [a[h], a[l]];
  }

  if (c(a[p], a[l]) < 0) {
    [a[l], a[p]] = [a[p], a[l]];
  }

  if (c(a[h], a[p]) < 0) {
    [a[h], a[p]] = [a[p], a[h]];
  }

  return p;
}
Select the pivot element using the median-of-three rule.

@see https://en.wikipedia.org/wiki/Quicksort#Choice_of_pivot

@param {Array} a The array to select a pivot in.
@param {number} l The lower index of the pivot selection.
@param {number} h The higher index of the pivot selection.
@param {Function} c The comparator function.
@return {number} The selected pivot.
@private