sort routes for more specific results

This change sorts the routes to get the most specific routes first and
avoid hitting a route which is not the most specific match.
With this the regex to extract variables is made more strict to avoid
matching half of the URI.