use n_th element in a container, but with another key
问题 I have two vectors. One that actually holds the data (let's say floats) and one that holds the indices. I want to pass at nth_element the indices vector, but I want the comparison to be done by the vector that actually holds the data. I was thinking about a functor, but this provides only the () operator I guess. I achieved that by making the data vector a global one, but of course that's not desired. std::vector<float> v; // data vector (global) bool myfunction (int i,int j) { return (v[i]<v