| Start |
|---|
| Sorting and sequence containers
The comparison function must impose a Strict, Weak Ordering (opens new window) on the elements. A simple less-than (or greater-than) comparison will suffice. A container with random-access iterators can be sorted using the
Their member |
| Sorting sequence containers with specifed ordering If the values in a container have certain operators already overloaded, In C++14, we don't need to provide the template argument for the comparison function objects and instead let the object deduce based on what it gets passed in: |
| Sorting sequence containers by overloaded less operator If no ordering function is passed, We can overload this operator to make the default |
Sorting sequence containers using compare function |
Sorting sequence containers using lambda expressions (C++11) |
| sorting with std::map (ascending and descending) This example sorts elements in ascending order of a key using a map.
You can use any type, including class, instead of Output: If entries with equal keys are possible, use To sort elements in descending manner, declare the map with a proper comparison functor ( Output |
| Sorting built-in arrays The Prior to C++11, end of array had to be "calculated" using the size of the array: RemarksThe |
Read Article
https://develop.horje.com/learn/1434/reference