Ordering four points into a closed quadrilateral with Wolfram

pts = {{0, 0}, {1, -1}, {1, 1}, {4, 0}}

How to use Mathematica code to reorder the coordinates of any four given points so that they are arranged (either clockwise or counterclockwise) as the four points of a closed quadrilateral as follows and so on. The polygon drawn with the reordered coordinates is shown in the right-hand panel above.

{{0, 0}, {1, -1}, {4, 0}, {1, 1}}

Or

{{1, -1}, {4, 0}, {1, 1}, {0, 0}}

Or

{{4, 0}, {1, 1}, {0, 0}, {1, -1}}

Extending the above problem: suppose we are given n arbitrarily ordered points that are known to form a simple closed n-gon; how can we reorder them—clockwise or counter-clockwise—so that the list can be used to plot the polygon correctly and compute its area?The purpose is to make the code universal.

If you can assume that the polygons should be convex, then you can use a convex hull.

MeshPrimitives[ConvexHullMesh[pts], 2] // InputForm
(* {Polygon[{{0, 0}, {1, -1}, {4, 0}, {1, 1}}]} *)

You could use FindShortestTour

There can be more than one reordering that makes a simple closed polygon. Here is my attempt:

properIntersection[{Line[pts1_], Line[pts2_]}] := 
 RegionDifference[RegionIntersection[Line[pts1], Line[pts2]], 
  Point[Join[pts1, pts2]]];
notSelfIntersectsQ[pts_?MatrixQ] := 
  RegionUnion @@ 
    Map[properIntersection, 
     Subsets[Map[Line, Partition[pts, 2, 1, {1, 1}]], {2}]] == 
   EmptyRegion[2];
findSimplePolygons[pts_?MatrixQ] := 
  Select[Map[Prepend[pts[[1]]], Permutations[Rest[pts]]], 
   notSelfIntersectsQ];
pts = {{0, 0}, {2, -3}, {1, -1}, {1, 1}, {4, 0}};
Graphics[Point[pts]]
reorderings = 
 findSimplePolygons[{{0, 0}, {2, -3}, {1, -1}, {1, 1}, {4, 0}}]
Map[Graphics@*Polygon, reorderings]

But there is only one reordering (CW or CCW) that maximizes the circumscribed area