X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/128234cde1ed0504d6beb0b2d10544feb2d77809..0c73a825d13bae50a00702852522202227d66676:/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py diff --git a/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py b/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py index ccee8185d..e89c54fae 100644 --- a/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py +++ b/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py @@ -35,6 +35,11 @@ def strategy_byparents(sequence): """ def partindices(item): + """Convert an entry a tuple of the indices of the entry's parts. + + >>> sequence = testsequence + >>> assert partindices("c/2/x") == (sequence.index("c"), sequence.index("c/2"), sequence.index("c/2/x")) + """ return tuple(sequence.index(item.rsplit('/', i)[0]) for i in range(item.count('/'), -1, -1)) return sorted(sequence, key=partindices)