how to sort a vector of pairs by value code example
Example: Sort by the distance between pairs c++
sort(begin(data), end(data),
[](pair<int, int> const& a, pair<int, int> const& b)
{
return abs(a.first-a.second)<abs(b.first-b.second);
});