I have a class that contains four data members, i.e.,
1 2 3 4 5 6 7 8 9
class ClassA
{
...
private:
int property1;
int property2;
int property3;
int property4;
};
I create a vector of these objects which I need to sort by any combination of these properties (one or more) in a generic way. For example, something like:
The solution has to be generic enough to avoid enumerating all possible combinations of sorting properties into respective "void sort...(...)" functions.
If all properties are of the same type and the type implements operator<, you could do it by using memory pointers, a small functor and the std::sort() function.