Update bubble_sort.py

This commit is contained in:
yyeltsyn 2016-08-26 09:02:54 +03:00 committed by GitHub
parent 456995580b
commit ab8340cac7

View File

@ -30,7 +30,7 @@ def bubble_sort(collection):
[-45, -5, -2] [-45, -5, -2]
""" """
length = len(collection) length = len(collection)
for i in range(length): for i in range(length-1):
for j in range(length-1): 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]