How do I have the algorithm below to sort my list in opposite direction (right to left) instead of left to right.
Also, how do I make it sort simultaneously or alternatively in both directions? Thanks.
def bubblesort(l): for passes in range(len(l)-1, 0, -1): for index in range(passes): if l[index] < l[index + 1]: l[index], l[index + 1] = l[index + 1], l[index] print l return l bubblesort([4,2,7,9,25])
Please use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help.
your Python code here