I am new to C ++ and I am trying to use the std :: sort function to sort the solution vector.
The code looks something like this (the list of solutions is a vector *):
void SolutionSet::sort(Comparator &comparator) { std::sort(solutionsList_->begin(), solutionsList_->end(), &comparator::compare); }
The comparator parameter is an instance of the Comparator child class, and the comparison method is virtual in the Comparator class and is implemented by all comparator child classes.
And I want to use this function as a comparator function in std: sort ().
Is it possible?
If so, can someone tell me how? Because it does not work with the previous code.
If I do not understand myself, just ask!
Thanks guys!
source share