Sort based on line names