Skip to content

Commit d310166

Browse files
committed
refactor(sorts): add type annotations to alphanum_key in natural_sort
1 parent 215c1f0 commit d310166

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎sorts/natural_sort.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ def natural_sort(input_list: list[str]) -> list[str]:
2424
['elm0', 'elm1', 'Elm2', 'elm9', 'elm10', 'Elm11', 'Elm12', 'elm13']
2525
"""
2626

27-
def alphanum_key(key):
28-
return [int(s) if s.isdigit() else s.lower() for s in re.split("([0-9]+)", key)]
27+
def alphanum_key(key: str) -> list[int | str]:
28+
return [
29+
int(s) if s.isdigit() else s.lower() for s in re.split(r"([0-9]+)", key)
30+
]
2931

3032
return sorted(input_list, key=alphanum_key)
3133

0 commit comments

Comments
 (0)