I'm starting to implement basic sorting algorithms. Criticisms on the implementation is welcome.
#import pudb; pu.db def bubble_sort(list_): """Implement bubblesort algorithm: iterate L to R in list, switching values if Left > Right. Break when no alterations made to to list. """ not_complete = True while not_complete: not_complete = False for val, item in enumerate(list_): if val == len(list_)-1: val = 0 else: if list_[val] > list_[val+1]: list_[val], list_[val+1] = list_[val+1], list_[val] not_complete = True return list_ if __name__ == '__main__': assert bubble_sort(list(range(9))[::-1]) == list(range(9))