冒泡排序

 1 lst = [1,3,45,6,4,43,4,5,6]
 2 def sort(lst):
 3     for i in range(0,len(lst)-1):
 4         for j in range(0,len(lst)-i-1):
 5             if lst[j] < lst[j+1]:
 6                 temp = lst[j]
 7                 lst[j] = lst[j+1]
 8                 lst[j+1] = temp;
 9     for m in lst:
10         print m
11 
12 if __name__ =="__main__":
13     sort(lst)

 


  

posted @ 2013-11-23 23:03  hiboy1  阅读(496)  评论(0)    收藏  举报