Sorting floating lines (end of next line has same x and y value as start from line next to it)

Hi
i have a bunch of lines. atm they are randomly sorted. i would like to get them sorted in one continous motion :slight_smile:

like this:

i tried projecting the lines on the floor and seeing what end goes with what start. but I don’t know how to procede from here :confused:

any tips?
thanks
chris

sort floating lines.gh (9.0 KB)

sort_floating_lines_re.gh (6.4 KB)

thanks :sunny: