KD-tree for rectangle query, build inO(NlogN) with nth_element