code: private void quickSelect(List<P> points, int splitAxis, int medianNum) {
  		int numPoints = points.size();
  
  		if( tmp.length < numPoints ) {
  			tmp = new double[numPoints];
  			indexes = new int[ numPoints ];
  		}
  		for( int i = 0; i < numPoints; i++ ) {
  			tmp[i] = distance.valueAt(points.get(i),splitAxis);
  		}
  
  		QuickSelect.selectIndex(tmp, medianNum, numPoints, indexes);
  	}
docs: Uses quick-select to find the median value