#include #include #include #include #include using namespace std; bool cmp( const int& a, const int& b ) { return a > b; } class CMP { string _note; public: CMP( const string& note) : _note( note) { } bool operator ()( const int& a, const int& b) { return a < b; } }; int main() { vector v; //list v; for( int i = 0; i < 10; i++ ) { v.push_back(i); } cout << "Before: "; for( int i = 0; i < 10; i++ ) { cout << v[i] << " "; } cout << endl; sort( v.begin(), v.end(), cmp ); cout << "After: "; for( int i = 0; i < 10; i++ ) { cout << v[i] << " "; } cout << endl; sort( v.begin(), v.end(), CMP("ascending")); cout << "After Second Sort: "; for( int i = 0; i < 10; i++ ) { cout << v[i] << " "; } cout << endl; return 0; }