# Written by Eric Martin for COMP9021


def bubble_sort(L):
    bound = len(L) - 1
    swapped = True
    while swapped and bound:
        swapped = False
        for i in range(bound):
            if L[i] > L[i + 1]:
                L[i], L[i + 1] = L[i + 1], L[i]
                swapped = True
                bound = i

Resource created Wednesday 21 October 2015, 10:11:20 AM.

file: bubble_sort.py


Back to top

COMP9021 15s2 (Principles of Programming) is powered by WebCMS3
CRICOS Provider No. 00098G