Skip to content
Snippets Groups Projects
Commit b138c5f9 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Refactor code based on recommendation

parent fb74c182
No related branches found
No related tags found
1 merge request!240Fix _repr_svg_ and refactor sorting
Pipeline #90583 passed
......@@ -24,8 +24,13 @@ _T = TypeVar('_T')
def _sorted_nicely(to_be_sorted: Iterable[_T]) -> List[_T]:
"""Sort the given iterable in the way that humans expect."""
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', str(key))]
def convert(text):
return int(text) if text.isdigit() else text
def alphanum_key(key):
return [convert(c) for c in re.split('([0-9]+)', str(key))]
return sorted(to_be_sorted, key=alphanum_key)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment