Advertisement
istinishat

vector pair sort first element inc. second dec.

May 26th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Comp {
  2.   bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
  3.     if (a.first != b.first) {
  4.       return a.first < b.first;
  5.     }
  6.     return a.second > b.second;
  7.   }
  8.  
  9. };
  10.  
  11. Comp comp_functor;
  12. std::sort(myVec.begin(), myVec.end(), comp_functor);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement