Horje
reverse sort a vector Code Example
how to sort a vector in reverse c++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
   vector<int> v = { 10, 9, 8, 6, 7, 2, 5, 1 };
   sort(v.begin(), v.end(), greater <>());
}
sort vector in reverse order c++
#include <iostream>
#include <vector>
#include <algorithm>
 
int main()
{
    std::vector<int> vec = { 7, 3, 5, 1, 9 };
 
    std::sort(vec.rbegin(), vec.rend());
 
    // do anything
 
    return 0;
}
reverse sort a vector
vector<int> v = { 10, 9, 8, 6, 7, 2, 5, 1 };
   sort(v.begin(), v.end(), greater <>());




Cpp

Related
ranged based for loop c++ Code Example ranged based for loop c++ Code Example
Explicit conversion casting Code Example Explicit conversion casting Code Example
visual studio getline not working Code Example visual studio getline not working Code Example
take single digit integer input in c++ Code Example take single digit integer input in c++ Code Example
return multiple values c++ Code Example return multiple values c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8