docs: protected void peanoSort(List<? extends SpatialComparable> objs, int start, int end, double[] mms, int[] dims, int depth, long[] bits, boolean desc) {
      final int numdim = (dims != null) ? dims.length : (mms.length >> 1);
      final int edim = (dims != null) ? dims[depth] : depth;
      // Find the splitting points.
      final double min = mms[2 * edim], max = mms[2 * edim + 1];
      final double tfirst = (min + min + max) / 3.;
      final double tsecond = (min + max + max) / 3.;
      // Safeguard against duplicate points:
      if(max - tsecond < 1E-10 || tsecond - tfirst < 1E-10 || tfirst - min < 1E-10) {
        boolean ok = false;
        for(int d = 0; d < numdim; d++) {
          int d2 = ((dims != null) ? dims[d] : d) << 1;
          if(mms[d2 + 1] - mms[d2] >= 1E-10) {
            ok = true;
            break;
          }
        }
        if(!ok) {
          return;
        }
      }
      final boolean inv = BitsUtil.get(bits, edim) ^ desc;
      // Split the data set into three parts
      int fsplit, ssplit;
      if(!inv) {
        fsplit = pivotizeList1D(objs, start, end, edim, tfirst, false);
        ssplit = (fsplit < end - 1) ? pivotizeList1D(objs, fsplit, end, edim, tsecond, false) : fsplit;
      }
      else {
        fsplit = pivotizeList1D(objs, start, end, edim, tsecond, true);
        ssplit = (fsplit < end - 1) ? pivotizeList1D(objs, fsplit, end, edim, tfirst, true) : fsplit;
      }
      int nextdim = (depth + 1) % numdim;
      // Do we need to update the min/max values?
      if(start < fsplit - 1) {
        mms[2 * edim] = !inv ? min : tsecond;
        mms[2 * edim + 1] = !inv ? tfirst : max;
        peanoSort(objs, start, fsplit, mms, dims, nextdim, bits, desc);
      }
      if(fsplit < ssplit - 1) {
        BitsUtil.flipI(bits, edim); // set (all but dim: we also flip "desc")
        mms[2 * edim] = tfirst;
        mms[2 * edim + 1] = tsecond;
        peanoSort(objs, fsplit, ssplit, mms, dims, nextdim, bits, !desc);
        BitsUtil.flipI(bits, edim);
      }
      if(ssplit < end - 1) {
        mms[2 * edim] = !inv ? tsecond : min;
        mms[2 * edim + 1] = !inv ? max : tfirst;
        peanoSort(objs, ssplit, end, mms, dims, nextdim, bits, desc);
      }
      // Restore ranges
      mms[2 * edim] = min;
      mms[2 * edim + 1] = max;
    }