how to bubble search in python stack overflow

Solutions on MaxInterview for how to bubble search in python stack overflow by the best coders in the world

showing results for - "how to bubble search in python stack overflow"
Martín
08 Nov 2018
1mylist = [12, 5, 13, 8, 9, 65]
2
3def bubble(badList):
4    length = len(badList) - 1
5    unsorted = True
6
7    while unsorted:
8        for element in range(0,length):
9            unsorted = False
10            if badList[element] > badList[element + 1]:
11                hold = badList[element + 1]
12                badList[element + 1] = badList[element]
13                badList[element] = hold
14                print badList
15            else:
16                unsorted = True
17
18print bubble(mylist)
19