Skip to content

Commit

Permalink
Merge pull request #170 from CelineLind/master
Browse files Browse the repository at this point in the history
Created bubbleSort.py
  • Loading branch information
vichitr authored Oct 19, 2019
2 parents 0b50031 + 352309f commit 5de1199
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Algorithms/Python/bubbleSort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# bubble sort

# test numbers
toSort = [3, 7, 2, 6, 4]

# perform bubble sort
for i in range(5):
for j in range(4):
if toSort[j] > toSort[j+1]:
temp = toSort[j]
toSort[j] = toSort[j + 1]
toSort[j + 1] = temp

# print sorted list
for x in toSort:
print(x)

0 comments on commit 5de1199

Please sign in to comment.