code: private static int partition(SortedListView list,
              int left, int right) {
          int i = left - 1;
          int j = right;
          while (true) {
              while (less(list.getDouble(++i), list.getDouble(right)))      // find item on left to swap
              ;                               // a[right] acts as sentinel
              while (less(list.getDouble(right), list.getDouble(--j))) // find item on right to swap
              {
                  if (j == left) {
                      break;           // don't go out-of-bounds
                  }
              }
              if (i >= j) {
                  break;                  // check if pointers cross
              }
              list.exhange(i, j);               // swap two elements into place
          }
          list.exhange(i, right);               // swap with partition element
          return i;
      }
docs: partition a[left] to a[right], assumes left < right