sorting vector of pairs 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);
});