I have a std::list<myclass*> and in my class I have myclass::operator<(myclass &other) defined.
I use the std::list.sort() function, but it does not change anything in that list. Maybe it just sorts the pointers?
How can I sort the actual items in that list?
You are sorting the pointer values, not the myclass values. You have to write your own predicate to compare pointers by dereference:
By the way, I think you cannot sort
std::listwithstd::sortfrom<algorithm>because it is not random access. Use the member functionsortinstead as MerickOWA says. (But that’s generally less efficient than sorting a random-access container.) Alternatively, you can immediately store your objects in a sorted container likestd::set<Foo*, PPred>, wherePPredis the functor version of the predicate: