1 parent 37bc6bd commit 3e75c0bCopy full SHA for 3e75c0b
1 file changed
sorts/bubble_sort.py
@@ -28,9 +28,9 @@ def bubble_sort(collection):
28
True
29
"""
30
length = len(collection)
31
- for i in range(length - 1):
+ for i in range(1, length):
32
swapped = False
33
- for j in range(length - 1 - i):
+ for j in range(length - i):
34
if collection[j] > collection[j + 1]:
35
swapped = True
36
collection[j], collection[j + 1] = collection[j + 1], collection[j]
0 commit comments