Merge pull request #231 from TheAlgorithms/revert-22-patch-1

Revert "Update bubble_sort.py"
This commit is contained in:
Harshil 2018-01-20 16:27:48 +05:30 committed by GitHub
commit bfd52dfa42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,8 +31,8 @@ def bubble_sort(collection):
[-45, -5, -2] [-45, -5, -2]
""" """
length = len(collection) length = len(collection)
for i in range(length-1, -1, -1):#range(length-1, -1, -1) for i in range(length):
for j in range(i):#range(1, i) for j in range(length-1):
if collection[j] > collection[j+1]: if collection[j] > collection[j+1]:
collection[j], collection[j+1] = collection[j+1], collection[j] collection[j], collection[j+1] = collection[j+1], collection[j]