Sort edges of surfaces

i have multiple surfaces and i have their corner points i need to sort the edges of the surface to be the same for all, so that index 1 is the top for example and it goes around clockwise. find attached the gh and rhino file.

files:
https://drive.google.com/drive/folders/1tK67leqRR2E-Po7g34AvlQuWcipqfZOr?usp=drive_link

Hi, would be helpful if you could attach internalized GH in your post directly. Can’t access Google drive.

I don’t think you need to use meshes at all, the BRep data structure allows you to inspect the edges. Then I think it you should be able to:

  1. determine the edge height either by the height of its start and end vertex, or by sampling a few points along the edge
  2. walk along the outer loop starting at the highest edge.
  3. sort these edges clockwise using the brep face normal.

There are some challenges in your file though:

  • not all Breps are oriented consistently, some have their normals pointing outwards where most have their normal pointing inwards. If you want to have a consistent clockwise ordering all normals must point in the same direction as the neighbor face.
  • there is at least one triangular face; it will not have a “top” edge.