Sorting a vector of pointers?


Hi, I have a vector of objects "students" with an overload < operator which allows me to sort it with the following command:

sort(students_list->begin(), students_list->end());

This works fine. However, I need to do the same with a vector of pointers to students. Is there a way I can use the sort() method on it, since the "<" operator is now applied to the pointers and not the student objects? Or will I have to code my own sorting algorithm?

Any help would be much appreciated!
You don't need to redefine much, just your comparison function used by std::sort. Have a look at CodeProject for a tutorial on how to define your own comparison functions for use with STL's sort algorithm.