There is a queue with a priority, in which QPair<int,int> lies QPair<int,int> you need to sort this queue depending on the second value of the pair. How to write a predicate? In theory, this is a functor that returns bool

 struct Compare { bool operator(const int& x, const int& y) const { return x > y; } }; 

Just how to tell him that he should work with the second value of the pair?

    1 answer 1

     struct Compare { bool operator()(const QPair& p1, const QPair& p2) { return p1.second > p2.second; } }; 

    or simply

     [](const QPair& p1, const QPair& p2) { return p1.second > p2.second; }