mitsuhiko/werkzeug — pull request #196 by jasonLaster (2012-06-29 21:16:19+00:00)
Title: Fix issue 185

This patch fixes the inconsistency brought up in issue \#185 "Complex URL routes are sorted incorrectly".

Instead of simply sorting by the number of parts in a rule, the router would now be smart enough to sort by the types of parts in the rule as well. The new heuristic counts the number of static parts, path parts, and other parts and then sorts lexographically in order:

+ number of static parts + weight fnc
+ number of other parts + weight fnc
+ number of path parts + weight fnc

where the weight function normalizes for the position of the various parts in the rule.