Another way to sort a sequence into descending order.
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
vector<char> vectorObject(26);
int i;
for(i = 0; i <vectorObject.size(); i++)
vectorObject[ i ] = 'A'+i;
cout << "Original ordering of vectorObject:";
for(i = 0; i <vectorObject.size(); i++)
cout << vectorObject[ i ] << " ";
cout << endl;
sort(vectorObject.begin(), vectorObject.end(), not2(less<char>())); // sort into desceding order
cout << "After sorting vectorObject using not2(less<char>()):";
for(i = 0; i <vectorObject.size(); i++)
cout << vectorObject[ i ] << " ";
return 0;
}
Related examples in the same category