update the shorest route routine to sort the routes