I have to use st::sort. In the cmp function I have, I want to have a variable that I have computed preveiously, but will be for all the cmp calls the same. Now, because I was eager to see my result, I placed the variable (P0) as global... :/ ( heartbreaking). Is there any way to do it a more elegant way?
And the relative code
Code:Point_2 P0; //global ... std::cout<<"SORT<----------------"<<std::endl; std::sort(P.begin(), P.end(), cmp); std::copy(P.begin(), P.end(), out); ... // Definition of the function bool cmp(const Point_2 &a, const Point_2 &b) { double aRad = findRad(a, P0); double bRad = findRad(b, P0); if(aRad < bRad) return true; if(aRad == bRad) { if(a.y() > b.y()) return true; else if(a.y() == b.y() && a.x() > b.x()) return true; else return false; } return false; }



2Likes
LinkBack URL
About LinkBacks
). Is there any way to do it a more elegant way?



