Need help in SPOJ 2DSORT

I am trying to solve SORT2D, the approach I am thinking of is using a vector<pair<int,int>> v and then sort(v.begin(),v.end() but then how do I compare the y co-ordinate’s position when x values are equal?

you have to use comparator here, you can read about it here
This code can help.

1 Like