Skip to content

Commit 3e75c0b

Browse files
update bubble sort
1 parent 37bc6bd commit 3e75c0b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sorts/bubble_sort.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def bubble_sort(collection):
2828
True
2929
"""
3030
length = len(collection)
31-
for i in range(length - 1):
31+
for i in range(1, length):
3232
swapped = False
33-
for j in range(length - 1 - i):
33+
for j in range(length - i):
3434
if collection[j] > collection[j + 1]:
3535
swapped = True
3636
collection[j], collection[j + 1] = collection[j + 1], collection[j]

0 commit comments

Comments
 (0)