# Order not closed curves in clockwise direction

Hello ! i am trying to order a group of curves either clockwise or counterclockwise, i tried many solutions that i found in the Grasshopper Forumss and it worked only in the cases where the curves were closed. my question is if there a way to order not closed curves clockwise or counterclockwise?
very appriated for any hint

Sorting curves clockwise.3dm (23.3 KB)

This could be one way:

1 Like

sort_edges_2021_Jul8a.gh (9.5 KB)

P.S. Oops, if you want âclockwise directionâ just reverse the resulting list.

Thank you so much @Joseph_Oster. this is exactly what i was looking for. just i have a question do you think its possible that the vectorâs direction follow this sequence as well ?

@Baris posted the same solution before I did.

Vectors, what vectors? Your eight line fragments donât touch each other, is that a concern?

by mistake i skipped your solution. Thank you so much, it worked perfectly @Baris

1 Like

Hi Joseph, it mattars for me because i am looking for getting at the end two lists the first one contains the current lineâs direction and the other one that contains the clockwise direction for each line to compare between them to get line which has an oppisite dirction of clockwise.

These vectors? Green group (in white group), along with corresponding line segments.

sort_edges_2021_Jul8b.gh (17.6 KB)

Sketchy though when so many line fragments donât meet. Feels like a mistake?

this soultion is great. Unfortunately the curves looks like that and they should not be attached to each other this way it made it complicated. i was just wondering why the lines cant be sperated lines after by explode?

There is nothing to explode, they are all just plain simple lines, not polylines.
This solution is prone to error.

This solution sorts along a circumscribed circle and appears to be more robust?

sort_edges_2021_Jul8c.gh (19.4 KB)

P.S. Stretching the top-left and top-right line segments demonstrates that version âcâ is indeed more robust than version âbâ, which is bad! (as I suspected) No code changes, only the internalized lines.