Deviation Actions

nephilim-wingless's avatar

bubble sort

Published:
0 Comments
314 Views
def BubbleSort(lst):
....lst = list(lst) #copy collection to list
....for passesLeft in range(len(lst)-1, 0, -1):
........set_print(lst)
........for i in range(passesLeft):
............if lst[i] > lst[i + 1]:
................lst[i], lst[i + 1] = lst[i + 1], lst[i]
....set_print(lst)

####################
def set_print(print_item):
....for i in range(len(print_item)):
........print print_item[i],
....print

print 'P2'
print str(1024)+' x'
print '255'
Bubblesort(g)
Image details
Image size
1024x1023px 124.96 KB
© 2011 - 2021 nephilim-wingless
Comments0
Join the community to add your comment. Already a deviant? Log In