hello,
 
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 
 

 


      
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to