There was an error while loading. Please reload this page.
1 parent 3f0532a commit 7f81fcdCopy full SHA for 7f81fcd
1 file changed
sorts/bubble_sort.py
@@ -74,7 +74,7 @@ def bubble_sort_iterative[T: Comparable](collection: list[T]) -> list[T]:
74
for i in reversed(range(length)):
75
swapped = False
76
for j in range(i):
77
- if collection[j] > collection[j + 1]:
+ if collection[j + 1] < collection[j]:
78
swapped = True
79
collection[j], collection[j + 1] = collection[j + 1], collection[j]
80
if not swapped:
@@ -143,7 +143,7 @@ def bubble_sort_recursive[T: Comparable](collection: list[T]) -> list[T]:
143
length = len(collection)
144
145
for i in range(length - 1):
146
- if collection[i] > collection[i + 1]:
+ if collection[i + 1] < collection[i]:
147
collection[i], collection[i + 1] = collection[i + 1], collection[i]
148
149
0 commit comments