Automatic horizontals

Hello
I have a set of horizontals that I want to raise to a certain mark. Some horizontals consist of 2-3 segments that I want to connect into one, but after that the order of the horizontals gets lost.
How can you connect segments horizontally so that their list coincides with their mark?
thank you



connection of curves.gh (17.7 KB)
connection of curves.3dm (258.7 KB)

I think that you can create a point in the middle of the numbers, import your curves into Grasshopper, join them, and sort the curves based on the closest point, in this case, the point from the numbers.

How to sort the lines by their correct marks?
thank you
connection of curves.gh (17.7 KB)

Is this what you are looking for?


Sorted_connection of curves.gh (98.2 KB)

thank you. Here is one option of how it can be done