# TODO: reformat the parameter specifications and add examples.
Topological sort
It is sometimes convenient to topological sort.
natsort_comparison
natsort_comparison (str1:str, str2:str)
Parameters - str1 - str - str2 - str
default_str_comparison
default_str_comparison (str1:str, str2:str)
Parameters - str1 - str - str2 - str
containing_string_priority
containing_string_priority (str1:str, str2:str)
*Returns 1, 0, -1 depending on whether one string contains the other.
TODO make the string containment criterion looser, e.g. finite Galois etale cover “contains” finite etale cover.
Parameters - str1 - str - str2 - str*
graph_for_topological_sort
graph_for_topological_sort (items_to_sort:collections.abc.Iterable[str], key_order:Callable[[str,str],int])
*Parameters - items_to_sort - Iterable[str] - key_order: Callable[[str, str], int] - Comparing str1 against str2 results in a positive number if str1 is “greater” than str2 (i.e. str1 is of a later priority)
Returns - dict[str, set[str]] - A dict whose keys are the elements k
of items_to_sort
and whose values are sets of elements k2
of items_to_sort
such that key_order(k, k2) > 0
.*
dict_with_keys_topologically_sorted
dict_with_keys_topologically_sorted (dict_to_sort:dict[str], key_order:Callable[[str,str],int], reverse:bool=False)
*Returns an OrderedDict whose keys are sorted topologically by the specified key order.
Parameters - dict_to_sort - dict[str] - The dict whose keys need to be ordered. - key_order - The comparison function on the keys of dict_to_sort
. Defaults to the key function for the comparison [
containing_string_priority](https://hyunjongkimmath.github.io/trouver/helper.topological_sort.html#containing_string_priority)
. - reverse - bool - Defaults to False
Returns - OrderedDict[str]*
# TODO: test