Sort Vector of Curve

From the image below, the start point begin from the left except one line, how do i write a script to search for line which had different vector. Then sort them in the direction from (0,0,0) to (1,0,0)

You could sort points along curve first and then sort list base on point orders.

sort (8.6 KB)

You can simply flip the curves with a guide curve to harmonise the curve direction.