Assuming that whatever objects the list holds implements a proper > operator.
Use :
mylist.sort(std::greater<T>());
T is type of container elements. eg. int, char, float, etc.
For T as objects you need to overload operator '>' or define your own comparator function
bool cmp(const T &lhs, const T &rhs)
{
//compare criteria
}
And then,
mylist.sort(cmp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With