The bubble up procedure by python

 

  
array = [ 1 , 6 , 7 , 2 , 9 , 4 ]
for i in range(len(array) - 1 , 1 , - 1 ):
for j in range(0,i):
if array[j] > array[j + 1 ]:
array[j],array[j
+ 1 ] = array[j + 1 ],array[j]
print array

Wow, Python is so powerful, Let start to enjoy it now!

你可能感兴趣的:(procedure)