code: public static double select(final double[] arr, int lo, int hi, final int pivot) {
      while (hi > lo) {
        final int j = partition(arr, lo, hi);
        if (j == pivot) {
          return arr[pivot];
        }
        if (j > pivot) {
          hi = j - 1;
        }
        else {
          lo = j + 1;
        }
      }
      return arr[pivot];
    }
docs: Gets the 0-based kth order statistic from the array. Warning! This changes the ordering
  of elements in the given array!
  
  @param arr The array to be re-arranged.
  @param lo The lowest 0-based index to be considered.
  @param hi The highest 0-based index to be considered.
  @param pivot The 0-based smallest value to pivot on.
  @return The value of the smallest (n)th element where n is 0-based.