We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab2161e commit 119da45Copy full SHA for 119da45
1 file changed
sorts/bubble_sort.py
@@ -30,8 +30,8 @@ def bubble_sort(collection):
30
[-45, -5, -2]
31
"""
32
length = len(collection)
33
- for i in range(length-1):
34
- for j in range(length-1):
+ for i in range(length-1, -1, -1):#range(length-1, -1, -1)
+ for j in range(i):#range(1, i)
35
if collection[j] > collection[j+1]:
36
collection[j], collection[j+1] = collection[j+1], collection[j]
37
0 commit comments