X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/a812692a50de69215a8267c7b0b1d7bf62bdfa32..f3696cca89bc2606e05269fc8cc15f6c96b13881:/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)