I have a std::list
and in my class I have myclass::operator<(myclass &other)
defined.
I use the std::list.sort
It'll sort the pointer as std::sort( Container ) use the operator< defined T. Here T is myclass*, then it is sorted using comparison over pointer.
You can pass a custom comparator functor to std::sort so make one take takes two myclass* and return the proper comparison :
template
struct ptr_comparison
{
bool operator()(T* a, T* b) { return *a < *b; }
};
list mylist;
// later
mylist.sort(ptr_comparison());