Yes: you can sort using a custom comparison function:
std::sort(info.begin(), info.end(), my_custom_comparison);
my_custom_comparison
needs to be a function or a class with an operator()
overload (a functor) that takes two data
objects and returns a bool
indicating whether the first is ordered prior to the second (i.e., first < second
). Alternatively, you can overload operator<
for your class type data
; operator<
is the default ordering used by std::sort
.
Either way, the comparison function must yield a strict weak ordering of the elements.