C++ 23 · Containers and algorithms

Sort with a custom order

Sort descending by passing a lambda comparator.

std::sort(v.begin(), v.end(), [](int a, int b) { return a > b; });

Official C++ 23 documentation

More containers and algorithms commands

All containers and algorithms commands · C++ 23 cheatsheet

Was this page helpful?