Sort points along curve issue

Hey guys, I can’t get the points sorted along the curve, so that I can make a loft between the two polylines. Can someone help me?

Sort points along curve issue.gh (397.2 KB)
sort points along surface issue

Oh my good, you safed my life, thank you very much! Could you tell me why this is necessary?