[Tutor] sorting algorithim

tonyon boyo taboyo22 at yahoo.com
Fri Apr 24 02:54:35 CEST 2009

i know how to print for bubble sort in python, is there a way to print each pass in the sort so i can see what happens at each step?  thanks
def bubblesort(list):
    for passes in range(len(list)-1, 0, -1):
        for index in range(passes):
            if list[index] < list[index + 1]:
                list[index], list[index + 1] = list[index + 1], list[index]
    return list
print bubblesort([3,2,66,5,22,62,61,16])


 And you will be hated by all for My name’s sake. But he who endures to the end shall be saved. Luke 13:13 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090423/0b4c93e0/attachment.htm>

More information about the Tutor mailing list