Hi,

I am struggling with this problem for weeks and I am almost to give up.

Let’s say I have a given number of polylines, in this case 166. In random order.

And I want to order them so they have path-like logic. I choose starting polyline, in this case southernmost one and start ordering them. Similar to this…

The best and cheapest way that almost completed the task, was this one:

sort mid-points by Y-values, pick the 1st for starting point,

plug it into P-Input of Sequantially-Sort-Points by neoarchaic (http://www.neoarchaic.net/resources/grasshopper/sequentially-sort-points-by-distance/),

and plug all mid-points into S-Input. This is the result…

165-indexed point/polyline is problematic, as let’s say 10% of all. It is almost good-enough.

I am aware that script is choosing the closest point until the list is exhausted, so 164-point had to choose 165 since no one else has left.

The best solution I can think of is to solve TravellingSalesman path through all mid-points, draw the polyline and sort mid-points on it, then sort plylines accordingly. I have tried converting this to line-network and applied native shortest walk component, but it only allows 2 points per path.

I know this is complex problem, at least for me, since I do NOT know scripting.

Do you have any suggestions?

Or if it this TSP approach is super-heavy/impossible is there a way to move this 165 indexed point to index 1, then shift all list after index 1 by one. Find next wrong index move it to correct one and so on. It is not problem if I do it manually, since there are 10-15 points to move. It is not necessary to have it perfectly ordered, as long as I don’t have neighboring indices with large number difference.

Thank you in advance.

Curves.gh (84.7 KB)