Fix a problem that prioritized routes not working. #1248

ref #1248 .
This patch is a way of solving which use sorted routes.
Please, review my code.