docs: public static double quickSelect(double[] data, int start, int end, int rank) {
      while(true) {
        // Optimization for small arrays
        // This also ensures a minimum size below
        if(start + SMALL > end) {
          insertionSort(data, start, end);
          return data[rank];
        }
  
        // Best of 5 pivot picking:
        // Choose pivots by looking at five candidates.
        final int len = end - start;
        final int seventh = (len >> 3) + (len >> 6) + 1;
        final int m3 = (start + end) >> 1; // middle
        final int m2 = m3 - seventh;
        final int m1 = m2 - seventh;
        final int m4 = m3 + seventh;
        final int m5 = m4 + seventh;
  
        // Explicit (and optimal) sorting network for 5 elements
        // See Knuth for details.
        if(data[m1] > data[m2]) {
          swap(data, m1, m2);
        }
        if(data[m1] > data[m3]) {
          swap(data, m1, m3);
        }
        if(data[m2] > data[m3]) {
          swap(data, m2, m3);
        }
        if(data[m4] > data[m5]) {
          swap(data, m4, m5);
        }
        if(data[m1] > data[m4]) {
          swap(data, m1, m4);
        }
        if(data[m3] > data[m4]) {
          swap(data, m3, m4);
        }
        if(data[m2] > data[m5]) {
          swap(data, m2, m5);
        }
        if(data[m2] > data[m3]) {
          swap(data, m2, m3);
        }
        if(data[m4] > data[m5]) {
          swap(data, m4, m5);
        }
  
        int best = bestPivot(rank, m1, m2, m3, m4, m5);
        final double pivot = data[best];
        // Move middle element out of the way.
        swap(data, best, end - 1);
  
        // Begin partitioning
        int i = start, j = end - 2;
        // This is classic quicksort stuff
        while(true) {
          while(i <= j && data[i] <= pivot) {
            i++;
          }
          while(j >= i && data[j] >= pivot) {
            j--;
          }
          if(i >= j) {
            break;
          }
          swap(data, i, j);
          i++;
          j--;
        }
  
        // Move pivot (former middle element) back into the appropriate place
        swap(data, i, end - 1);
  
        // Skip duplicates to narrow down the search interval:
        while(rank < i && data[i - 1] == pivot) {
          --i;
        }
        while(rank > i && data[i + 1] == pivot) {
          ++i;
        }
  
        // In contrast to quicksort, we only need to recurse into the half we are
        // interested in. Instead of recursion we now use iteration.
        if(rank < i) {
          end = i;
        }
        else if(rank > i) {
          start = i + 1;
        }
        else {
          break;
        }
      } // Loop until rank==i
      return data[rank];
    }