sorting a vector of pairs based on second element 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);
});