Comparator for vector<pair<int,int>> [duplicate]
问题 This question already has answers here : How do I sort a vector of pairs based on the second element of the pair? (7 answers) Closed 6 years ago . vector<pair<int,int> > v; for(i=0;i<5;i++){ cin>>b>>c; v.push_back(make_pair(b,c)); } sort(v.begin(),v.end()); Is it possible to write a comparator for the sort function such that v[i].first is sorted in increasing order and for similar values of v[i].first , v[i].second is sorted in decreasing order? like:- i/p: 13 10 44 15 13 15 13 99 6 45 o/p: 6