Creating a new curves from nearby start / end points

This topic is about ordering and orienting lines that @jacob.small helped me with recently. The first script re-orders lines and the second script also changes their orientation.

Assuming you want to connect all the start (or all the end) points in sequence, you can try this:

If the start points are not consistently on the same end, you can try this: