You need a stable sorting algorithm (the witch does not change the order of equal elements). First, sort by y coordinate and the next x sort to get the desired result:
std::stable_sort(points.begin(), points.end(), yComparator()); std::stable_sort(points.begin(), points.end(), xComparator());
For instance:
to: (x, y) = (2,2), (2,3), (1,2), (1,3), (2,1), (1,1), (3,2), (3.3), (3.1)
(2,1), (1,1), (3,1), (2,2), (1,2), (3,2), (2,3)), (1,3), ( 3.3)
(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1)), (3,2), ( 3.3)