From 47f963e4912ce8e765cf0f724e5d19f2cecd4bce Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Wed, 1 Aug 2018 12:00:08 -0400 Subject: Added alphabetical_sort() function --- cmd2/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cmd2/utils.py') diff --git a/cmd2/utils.py b/cmd2/utils.py index d8afd922..d8bdf08d 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -157,3 +157,12 @@ def remove_duplicates(list_to_prune: List) -> List: temp_dict[item] = None return list(temp_dict.keys()) + + +def alphabetical_sort(list_to_sort: List[str]) -> List[str]: + """ + Sorts a list of strings alphabetically + :param list_to_sort: the list being sorted + :return: the sorted list + """ + return sorted(list_to_sort, key=str.casefold) -- cgit v1.2.1