sort vector in descending order

Solutions on MaxInterview for sort vector in descending order by the best coders in the world

showing results for - "sort vector in descending order"
Abigail
28 May 2017
1#include <iostream>
2#include <vector>
3#include <algorithm>
4using namespace std;
5int main() {
6   vector<int> v = { 10, 9, 8, 6, 7, 2, 5, 1 };
7   sort(v.begin(), v.end(), greater <>());
8}
Andrea
19 Mar 2017
1int main() 
2{ 
3    // Get the vector 
4    vector<int> a = { 1, 45, 54, 71, 76, 12 }; 
5  
6    // Print the vector 
7    cout << "Vector: "; 
8    for (int i = 0; i < a.size(); i++) 
9        cout << a[i] << " "; 
10    cout << endl; 
11  
12    // Sort the vector in descending order 
13    sort(a.begin(), a.end(), greater<int>()); 
14  
15    // Print the reversed vector 
16    cout << "Sorted Vector in descendiing order:n"; 
17    for (int i = 0; i < a.size(); i++) 
18        cout << a[i] << " "; 
19    cout << endl; 
20  
21    return 0; 
22} 
Tom
16 Jan 2016
1sort(a.begin(), a.end(), greater<int>());
2
queries leading to this page
c 2b 2b sort in descending orderhow to sort a vector in reverse order in cppvectort sort in cpphow to sort vector c 2b 2bhow to sort a vector in c 2b 2b reverselyhow to sort a vector in reverse order c 2b 2bsort vector descending order c 2b 2breverse sort c 2b 2bhow to sorrt a vectorhow to sort vector in descending order 3fvector sort c 2b 2b descendingsort vector in descending order cppsort a vector in reverse order c 2b 2bhow to sort in reverse order of vectorin c 2b 2bhow to sort a vector in c 2b 2b reversesort a vector c 2b 2b stlsorting vector in reverse orderc 2b 2b function for descending order vectorhow to sort a vector in c 2b 2bsorting vector in descending orderhow to sort vector in descending order c 2b 2b objectsreverse the vector in c 2b 2bvector sorthow to sort vector in descending ordersort in vectorreverse sort an vectorhow to sort vector elements in decreasing orderhow to reverse in vector in c 2b 2bhow to sort a vector array in c 2b 2bsort vector arrsort reverse vector in c 2b 2breverse a vector in c 2b 2bsort in stl vectordescending order sorting in vectorsort in descending order vectorsort reverse of vector elements in cppsorting a vector in descending ordervector sort decreasing orderis sorting c 2b 2b in reversedescending sort function vector c 2b 2bsort in decending in c 2b 2b stlalgorithm to sort a vector in descending orderc 2b 2b sort in reverse orderprint a vector in c 2b 2b in reverse ordersort the vector in descending orderdesc sort vectorhow to write a sorting algorithm in descending order in c 2b 2b for a vectorfunction to sort vector in descendingreverse sort a vectorhow to sort vector in reverse order inc 2b 2breverse sort function c 2b 2bsort a vector in descending order cppreverse sort vectorreverse comparator stlstd sort descendingsort all in rever order c 2b 2breverse sorting in vectorsort a vector in descending order in cppprint vector in reverse order c 2b 2bsort vector in descending order c 2b 2b in o 28n 29descending order using vector c 2b 2bsorting in descending order c 2b 2b vectorsort vector in decreasing order c 2b 2bhow to sort vector in descending order c 2b 2bsort in descending order c 2b 2b vectorhow to sort elements in vector c 2b 2bsort a vector in descending order in c 2b 2bc 2b 2b sort descendingsort vector in descendinghow to sort array in decreasing order with vectorshow to sort in decreasing order in c 2b 2b vectorsort a vector in reverse in c 2b 2bsort vector using stl in descending orderorder a vector in descending ordersort vector c 2b 2b greatersort vector ascending c 2b 2breverse a vector in cppsort cpp vector 2d reversesort vector descending in cppsorting the vector in c 2b 2bc 2b 2b how to reverse a vectorvactor sorting in decreasing c 2b 2bsort using c 2b 2b vectorssort vector reversec 2b 2b sort vector revershow to reverse sort vec in cpphow to sort a vector cppsort a vector in descending ordersort a vector in decreasing order in c 2b 2bhow to reverse sort a vector in c 2b 2bhow to sort in descending order in sort in c 2b 2bprint vector elements in reverse order c 2b 2bsorting a vector in increasing order in c 2b 2breverse sorting in vectors c 2b 2bc 2b 2b sort vector reverse ordersort vector c 2b 2b descendingc 2b 2b std sort descendingreverse sort c 2b 2b vectorcpp sort backwardshow to sort the vector in ascending ordersort lowest to highest vector c 2b 2bsort in reverse in c 2b 2bvector sort in decreasing orderhow to sort vector in reverse orderc 2b 2b sort vector in discending ordervector reverse function in c 2b 2bsort reverse vector c 2b 2bsort backwards c 2b 2bvector in decresring ordervector sort in reverse ordersort vector element in descending order c 2b 2bhow to reverse sort an vector array in c 2b 2bvector descending order c 2b 2bc 2b 2b reverse sorthow to sort vector array in c 2b 2bc 2b 2b sort descending vectorreverse sorting vector cpphow to reverse sort vector in c 2b 2b using rbeginhow to sort a vector in reverse orderhow to sort a vector using stlorder vector values in descending orderhow to sort an vector in decresing ordersort vector big to smal 3blc 2b 2b reverse vectorsort vector c 2b 2b 28descending 29sort a vector in reverse order stlsorting a vector in descending order in c 2b 2bsort string vector in descending order using sort 28 29sort vector in c 2b 2b in descendinghow to sort vector within vector in descending orderhow to reverse a vector c 2b 2bhow to vector by decreasing orderhow to sort vector using stl in reversevector sort decreasingsort vector descending order in c 2b 2bhow to descending sort a vectorc 2b 2b sort vector in reverse ordervector sortreverse a vector c 2b 2bsorting a vectorreverse sort of vector in cppvector sort in descending ordersort vector c 2b 2b descending time complexitydescending sort vector c 2b 2bhow to print vector in reverse order c 2b 2bsort a vector in decreasing order c 2b 2bsort descending vector c 2b 2bhow to use sort in descending order cppsort vector in decreastig ordersorting vector in descending order in c 2b 2bhow to print elements of vector in reverse order in cppvector sort in c 2b 2brepitations in the vector in descending ordersort vector in decreasing order cppsort vector in descending order using sort 28 29sort in reverse order c 2b 2breverse sort vector c 2b 2bvector reverse sorthow to sort an vector in descending order c 2b 2bsorting a vector stlhow to reverse vector c 2b 2bhow to sort object vector in descending order c 2b 2b sorting vector of pairs in descending orderhow to reverse a vector in c 2b 2bsort descending c 2b 2b vectorsort c 2b 2b stl vector in descending ordersort vector in reverse ordersort vector reverse c 2b 2bc 2b 2b reverse sort int vectorsorting a vector in reverse ordersort a vector in reversevector sort on treenodes c 2b 2bc 2b 2b vector sort descendingsort vector in decreasing order using sort 28 29vector sorting in c 2b 2bsort in descendig order vectorreverse sort stlsorting vector in descendingc 2b 2b std vector sort descendingsort a vector of integers in cpp reversesorted vector datatypereverse sorting of a vector in c 2b 2bvector reverse order in calgorithm to sort a vector in descending order without stlc 2b 2b std sort vector descendingreverse sort a vector c 2b 2bsorting vector in c 2b 2b stlsorting vector arraysort reverse c 2b 2b sort vector in decreasing order how to sort elements in a decending order vector c 2b 2barray sort descending vectorsort by highest vector cppdescending sort vectorsorting vector in c 2b 2b using stlsort in decreasing order in c 2b 2b vectorsort vector c 2b 2b in reversec 2b 2b vector descending sortnumber of repitations in the vector in descending ordersort 1d vector c 2b 2b descendingsort in descending order of vector in c 2b 2bvector sort descendinghow to sort vector in c 2b 2b in descending orderhow to sort a vector descending in c 2b 2bsort for vector c 2b 2bsort vector decreasing c 2b 2bc 2b 2b reverse sort vectorstl sort vector c 2b 2bhow to reverse c 2b 2b vectorordre vector in chow to sort vector in reverse order in c 2b 2b stlvector sort reversesorting vector in c 2b 2bhow to sort vector of vector in descending ordersorting in reverse order c 2b 2bsort increasin gorder using stl in c 2b 2bsort vector in descending order in c 2bsort vector in ascending order c 2b 2bhow to sort vector in descending order un mathsorting vectirsort descending oreder using sort vectorhow to sort a vector in descending orderfunction for reverse sorting in vectorsort in reverse order c 2b 2b vectorc 2b 2b sort vector in descensort vector in reverse order c 2b 2bsort vectorsort an vector in c 2b 2bsort vector in descending order in c 2b 2bsorting a vector in descending order c 2b 2bsort vector in reveerse stlsorting vector array in reverse c 2b 2bvector sort cppsort a vectorc 2b 2b sort vector descendinghow to sort in vector in reverse order in c 2b 2bvector desc sorthow to sort vector in desc order in c 2b 2bvector sort in reverse order c 2b 2bsort in vector cppsort vecotr using comparecpp sorting a vector in decening orderhow to sort an vector arrayhow to sort a vector in descending order c 2b 2bhow to sort vectro in cpp reverse array in c 2b 2b using vectorsort vector in reverse ordersort in decreasing order c 2b 2b vectorsort vector in descendeing ordeefunction vector parameter print sortsort a vector beased on 2nd vectorc 2b 2b vector into descending setsort a vector in c 2b 2b in decreasing ordersort vector in c 2b 2bsort a vector in descending in cppsort vector in stlhow to reverse sort vector in c 2b 2bsorting algorithms in descending order c 2b 2b vectors in a functionsort the vector a in reverse orderreverse sort a vector in c 2b 2bsort numbers in descending order c 2b 2b single elementreverse sort vector in c 2b 2b stlhow to sort and print a vector in stlsort vector by decreasing order c 2b 2bvector reverse c 2b 2breverse vector c 2b 2bsort vector c 2b 2b reversec 2b 2b vector sorthow to sort a vector in descending order using stl in c 2b 2b 3fc 2b 2b int decreasing ordersort a vector in reverse ordersort vector cppsort in decreasing order vector c 2b 2breverse sort in c 2b 2b vectorhow to sort a vector from greatest to leasthow to sort vector decresing ordersorting in vector c 2b 2bhow to sort array in descending order in c 2b 2b vectorhow to sort vector in decreasing irderhow to sort a vector in descending order in c 2b 2bhow tp reverse vector c 2b 2bsorting the vectorssort a vector in descending order c 2b 2bhow to sort a vector in reverse c 2b 2bsort in decreasing order in vectorstl to sort vectorhow to sort a vector from least to greatesthow to sort vectorc 2b 2b vector reversesort and reverse vectorsprt vector in descending orderreverse sorting vector in c 2b 2bvector sort descending c 2b 2bsorting vector in descending order in cppsort vector in descending order c 2b 2bhow to reverse vector in cppsort a vector in decreasing ordersort in descending order vector cppsorting in reverse in cppsort vector of strings in descending order stlsort vector descending c 2b 2bort the vector a in reverse orderc 2b 2b sort vector reversesort for vector in c 2b 2bsorting in vectorhow to reverse sort in c 2b 2b vectorsorting vector in descending order c 2b 2bstl sort on vectorsort in descending order vector c 2b 2bsort vector in decreasing orderc 2b 2b vector in descending ordersorting a vector in c 2b 2bhow to sort the vector in descending ordersort a vector in c 2b 2bsort vector stlhow to sort in descending order in c 2b 2b using sort function vectorreverse everything in a vector c 2b 2bvector decreasing ordervector sort in descending order c 2b 2bsort vector in c 2b 2b in descending orderhow to reverse vector in c 2b 2bcollection sort vector in descending ordersort vector descendingreverse sort a vector in cppsort vector in desending orderhow to sort vector array in descending ordersort using comparator vector pair in cppsort vector c 2b 2bhow to sort a vector array in decreasing orderhow to sort a vector in cppprint a vector reverse order c 2b 2bsort vector in descending orderc 2b 2b sort vector in descending ordersorting vectorhow to sort the vector in c 2b 2bsort in descending vectordecreasing order sort c 2b 2b long long vectorvector sort least to greatestsorting vector in decreasing ordersort vector values in descending orderreverse sort vector in c 2b 2bc 2b 2b vector sort reversesort vector in descending order using comparatorstl reverse sort c 2b 2bdescending order vector c 2b 2bsort function in c 2b 2b decreasing order vector 3cvector 3ehow to reverse sort a vector c 2b 2bsort decreasing c 2b 2b vectorhow to sort int vector in c 2b 2b in descending ordersort function in vector in descending order c 2b 2bhow to sort vector in descending order in c 2b 2bsort vector decendingsorting algorithms in descending order c 2b 2b vectorsstl function to sort in decreasingstl sorting a vectorreverse everything in a vectorsort vector in descending order