# Revision history [back]

Hi @konstunn!

Contours are aligned in opencv as a hierarchy of parent & child contours based on the type of Contour approximation method you choose for detailed explanation refer this wiki.

If you are having a Vector of Points & you want to sort these points you can refer this code:

bool SortbyXaxis(const Point & a, const Point &b)
{
return a.x < b.x;
}
bool SortbyYaxis(const Point & a, const Point &b)
{
return a.Y < b.Y;
}

vector<Point> Points;
sort( Points.begin(), Points.end(), SortbyYaxis );
sort( Points.begin(), Points.end(), SortbyXaxis );


Hi @konstunn!

Contours are aligned in opencv as a hierarchy of parent & child contours based on the type of Contour approximation method you choose for choose. For detailed explanation refer this wiki.

If you are having a Vector of Points & you want to sort these points you can refer this code:

bool SortbyXaxis(const Point & a, const Point &b)
{
return a.x < b.x;
}
bool SortbyYaxis(const Point & a, const Point &b)
{
return a.Y < b.Y;
}

vector<Point> Points;
sort( Points.begin(), Points.end(), SortbyYaxis );
sort( Points.begin(), Points.end(), SortbyXaxis );

 3 No.3 Revision sturkmen 6772 ●3 ●48 ●79 https://github.com/stu...

Hi @konstunn!

Contours are aligned in opencv as a hierarchy of parent & child contours based on the type of Contour approximation method you choose. For detailed explanation refer this wiki.

If you are having a Vector of Points & you want to sort these points you can refer this code:

bool SortbyXaxis(const Point & a, const Point &b)
{
return a.x < b.x;
}
bool SortbyYaxis(const Point & a, const Point &b)
{
return a.Y < b.Y;
}

vector<Point> Points;
sort( Points.begin(), Points.end(), SortbyYaxis );
sort( Points.begin(), Points.end(), SortbyXaxis );