mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-18 16:27:02 +00:00
for better bubble sort
This commit is contained in:
parent
ab2161e470
commit
119da45c52
|
@ -30,8 +30,8 @@ def bubble_sort(collection):
|
|||
[-45, -5, -2]
|
||||
"""
|
||||
length = len(collection)
|
||||
for i in range(length-1):
|
||||
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)
|
||||
if collection[j] > collection[j+1]:
|
||||
collection[j], collection[j+1] = collection[j+1], collection[j]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user