I was trying to resort a set when i realised that it was impossible to resort a set and i had to create a new set and have a custom sort function to resort it . I researched onl
This would be an easier way to do it:
#include
struct SortByYX
{
bool operator ()(const Point2D& lhs, const Point2D& rhs) const
{
return std::tie(lhs.y, lhs.x) < std::tie(rhs.y, rhs.x);
}
};
Then
set p2d_set2(p2d_set.begin(), p2d_set.end());
Edit: std::tie requires C++11 support, but if you don't have it you can use std::tr1::tie from , or boost::tie if you don't have TR1.