Determine close poligoni from points list in casual order

Hi all I have a list of points in casual order and that points are the contour of some polygons. There is an algorithm to determine close lines of poligons
Many thanks

What is “casual order”? Is it in an order that is not following the perimeter of the polygon?
Which type of polygon? Do you mean, by any chance, a convex polygon and you would like the vertices of the convex hull in order
as you traverse its perimeter in some direction (e.g. counterclockwise)? If this is the case there are these algorithms for computing the convex hull

You can use scipy.spatial.ConvexHull, if you don’t need to implement your own.

thank you for your answer, in particular I have for example an stl file. I take all the points with the same z coordinate and I obtain a list of points in not particular order.
I would like extract different sublist of points which describe each poligons that you can see from the example picture.
test
I have 4 pictures and rectangular external contour

many thanks