Sorted 0 1 2 3 4 5 6 7 8 9
How to sort in descending order?
sort() takes a third parameter that is used to specify the order in which elements are to be sorted. We can pass “greater()” function to sort in descending order. This function does comparison in a way that puts greater element before.
Sorted 9 8 7 6 5 4 3 2 1 0
How to sort in particular order?
We can also write our own comparator function and pass it as a third parameter.
Intervals sorted by start time : [1, 9] [2, 4] [4, 7] [6, 8]
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Sorting 2D Vector in C++ | Set 1 (By row and column)
- Sorting Vector of Pairs in C++ | Set 1 (Sort by first and second)
- Sorting 2D Vector in C++ | Set 3 (By number of columns)
- Sorting of Vector of Tuple in C++ (Descending Order)
- Sorting of Vector of Tuple in C++ (Ascending Order)
- Sorting 2D Vector in C++ | Set 2 (In descending order by row and column)
- Keep track of previous indexes after sorting a vector in C++ STL
- Sorting Vector of Pairs in C++ | Set 2 (Sort in descending order by first and second)
- vector::push_back() and vector::pop_back() in C++ STL
- How to flatten a Vector of Vectors or 2D Vector in C++
- vector::crend() & vector::crbegin() with example
- vector :: cbegin() and vector :: cend() in C++ STL
- vector::front() and vector::back() in C++ STL
- vector::empty() and vector::size() in C++ STL
- vector::at() and vector::swap() in C++ STL
- vector::begin() and vector::end() in C++ STL
- Sorting a Map by value in C++ STL
- sorting in fork()
- Structure Sorting (By Multiple Rules) in C++
- Sorting Array Elements By Frequency | Set 3 (Using STL)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.