Source

Sort this messy list / bubble.py





class Bubble(object):
    """
    Bubble sort - O(n^2)
    """
    def __init__(self, l):
        self.unsorted_list = l

    def sort(self):
        l = self.unsorted_list
        for i in range(len(l)):
            for j in reversed(range(i,len(l))):
                if l[j]<l[j-1]:
                    t=l[j]
                    l[j]=l[j-1]
                    l[j-1]=t