Skip to content

Commit

Permalink
Merge pull request TheAlgorithms#27 from AlvinPH/bubble_sort_MD1
Browse files Browse the repository at this point in the history
 better bubble sort
  • Loading branch information
dynamitechetan authored Sep 11, 2016
2 parents ab2161e + 119da45 commit 753f4c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sorts/bubble_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit 753f4c5

Please sign in to comment.