I have a convex polygon ABCDE... (it can have any number of points). I need to sort all its vertexes so none of the edges will intersect.
example:
A _____ B
\ /
\ /
X
/ \
/___\
C D
That polygon in ABCD order has intersecting edges. however in ABDC order:
A _____ B
| |
| |
| |
| |
|___|
C D
None of the edges intersect so ABDC is the expected output.
How can I do this?