def bubble(lst): swap = 'True' counter = 0 n = len(lst) m = len(lst) while swap == 'True': for j in range(n-1): if lst[j] > lst[j+1]: lst[j],lst[j+1] = lst[j+1],lst[j] counter += 1 swap = 'True' else: swap = 'False' n = n - 1 return counter
How do I shorten the time this function takes because I want to use it on a larger list.