We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e09bf50 + 25c0bd3 commit f98a5f7Copy full SHA for f98a5f7
sorts/insertion_sort.py
@@ -30,9 +30,8 @@ def insertion_sort(collection):
30
[-45, -5, -2]
31
"""
32
for index in range(1, len(collection)):
33
- while 0 < index and collection[index] < collection[index - 1]:
34
- collection[index], collection[
35
- index - 1] = collection[index - 1], collection[index]
+ while index > 0 and collection[index - 1] > collection[index]:
+ collection[index], collection[index - 1] = collection[index - 1], collection[index]
36
index -= 1
37
38
return collection
0 commit comments