usr bin env python def compGT return def bubblesort array funcCMP for

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
def compGT(a, b):
return a>b
def bubblesort(array, funcCMP):
for i in xrange(len(array)):
t = array[i]
for j in xrange(i-1, -1, -1):
if funcCMP(array[j], t):
array[j+1] = array[j]
array[j] = t
if __name__ == "__main__":
a = [1, 2, 4, 3, 5, 0, 6, 9, 3, 100, 99, 88, 7]
bubblesort(a, compGT)
print a