Skip to content

Commit 81c46df

Browse files
authored
[mypy] Add/fix type annotations for quick_sort(TheAlgorithms#4085) (TheAlgorithms#4215)
Co-authored-by: goodm2 <4qjpngu8mem8cz>
1 parent 6bb9a02 commit 81c46df

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sorts/quick_sort.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
For manual testing run:
88
python3 quick_sort.py
99
"""
10+
from typing import List
1011

1112

1213
def quick_sort(collection: list) -> list:
@@ -26,8 +27,8 @@ def quick_sort(collection: list) -> list:
2627
if len(collection) < 2:
2728
return collection
2829
pivot = collection.pop() # Use the last element as the first pivot
29-
greater = [] # All elements greater than pivot
30-
lesser = [] # All elements less than or equal to pivot
30+
greater: List[int] = [] # All elements greater than pivot
31+
lesser: List[int] = [] # All elements less than or equal to pivot
3132
for element in collection:
3233
(greater if element > pivot else lesser).append(element)
3334
return quick_sort(lesser) + [pivot] + quick_sort(greater)

0 commit comments

Comments
 (0)