I have a std::vector called foo_vec containing objects of class Foo. Suppose that Foo has a member variable int x, and I also implemented a function CompareInts(int a, int b) which returns the minimum of a and b. Then, I could do an std::sort the vector in terms of the object's x values.
However, what if these x values are not member variables of Foo, but are in another std::vector called x_vec. Here, the first element of x_vec corresponds to the first element of foo_vec, and so on. How can I perform an std::sort on foo_vec based on the corresponding values in x_vec?