#include #include #include #include using namespace std; struct X { pair p; }; bool myf(X a, X b) { return a.p.second > b.p.second; } int main(void) { X a; a.p.first = "a"; a.p.second = 1; X b; b.p.first = "b"; b.p.second = 2; X c; c.p.first = "c"; c.p.second = 3; vector v; v.push_back(a); v.push_back(b); v.push_back(c); for (unsigned i = 0; i < v.size(); i++) { cout << v[i].p.first << endl; } sort(v.begin(), v.end(), myf); cout << endl; for (unsigned i = 0; i < v.size(); i++) { cout << v[i].p.first << endl; } }