union/merge the polylines so it forms one polyline
split at vertices. Only works for segments joined at vertices without intervening nodes
Or you will have to get the pieces into a list, then (in this case), sort the polylines lexicographically (sort by X coordinates), then reassemble in that order.
Or start with the leftmost polyline, flip if necessary so that it points East, and find the next segment that shares the end node, flip if necessary, then merge the two segments... repeat with the remaining polyline segments.
Essentially, the latter is a spanning tree amongst start and endpoints, while retaining the connecting polyline.