std::list<T,Allocator>::sort (3) - Linux Man Pages
void sort(); (1)
template< class Compare > (2)
void sort( Compare comp );
Sorts the elements in ascending order. The order of equal elements is preserved. The first version uses operator< to compare the elements, the second version uses the given comparison function comp.
If an exception is thrown, the order of elements in *this is unspecified.
comp - While the signature does not need to have const &, the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) Type1 and Type2 regardless of value_category (thus, Type1 & is not allowed
Approximately N log N comparisons, where N is the number of elements in the list.
std::sort requires random access iterators and so cannot be used with list. This function also differs from std::sort in that it does not require the element type of the list to be swappable, preserves the values of all iterators, and performs a stable sort.
// Run this code