Revert "Use std::nth_element to partially sort the input vector"

This reverts commit b3d6503d3b235e05d2eee6b71111c7e3eea76178.

The results of seeding changed in a subtle way in the commit. If the
elements can have equal coordinates (in either or both dimensions),
the "Wirth algorithm" and std::nth_element sort the vector in
different order, leading to different order of nodes in the tree, and
different order of values returned by the kdtree search. If the
algorithm using the kdtree search is sensitive to the order of values,
results may change.
Fix a subtle bug in recSearch()

If the elements can have identical coordinate (in either or both
dimensions), the right sub-tree/child node can have elements with
coordinate equal to dimCurrMax. This should be rather rare though.