I've found some posts and known that radom points could be sorted using a ciecle. Then a non self intersection polyline could be drawn follwoing the sorted point order. However, in my case, I need every conncetion between two points to be right angle. I tried to create circles between every two points and made horizontal or vertical line from the start point to find intersection points between circles and connection lines. In this way, in can ensure that all the connection are right angle. And in order to void self intersecton, I picked the intersection point that was not in its previous circles. It worked for most cases.But, When points are really close to each other, circles may be nested. In this case, a self intersection seems unlinkely to avoid unless point order be swiched. I'm worried if an order switch would cause more intersections to its following connections. Are there any other algorithms to solve the problem? Thanks.