rearrange routes according to priority