Can you please help me with the following code (I am trying to order points in a counterclockwise way according their relative position to a fixed point):
Manipulate[Module[{opts},
opts = SortBy[Rest[pts],
Arg[(Complex @@ #) - (Complex @@ pts[[1]])] &];
Column[{Graphics[{Line[opts]}, PlotRange -> {{0, 45}, {0, 30}},
ImageSize -> {450, 300}], pts, opts}]],
{{pts, {{10, 10}, {35, 10}, {20, 20}, {20, 15}}}, Locator}]
After running it I get the output attached as Problem1.jpg
On the other hand, when I click on the point at (20,15), I get the output attached as Problem2.jpg
SortBy did not do anything until the Locator was clicked. And until I click on all the Locator points, the ordering is not correct. Can you tell me the reason for this, and how to fix it?
Attachments: