how to sort vector of pairs in c++ 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);
});
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);
});