Skip to content

Commit

Permalink
fix bug in bubble_sort to move made_swap between two loops
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryderry committed Oct 18, 2018
1 parent 122e1e7 commit b0b538b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/11_sorts/sorts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
def bubble_sort(a: List[int]):
if len(a) <= 1: return

made_swap = False
for i in range(len(a)):
made_swap = False
for j in range(len(a) - i - 1):
if a[j] > a[j+1]:
a[j], a[j+1] = a[j+1], a[j]
Expand Down

0 comments on commit b0b538b

Please sign in to comment.