First draft of the route sorting method