We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e09bf50 commit 25c0bd3Copy full SHA for 25c0bd3
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