[Python] python 冒泡法排序代码 →→→→→进入此内容的聊天室

来自 , 2019-12-01, 写在 Python, 查看 98 次.
URL http://www.code666.cn/view/41da609c
  1. def BubbleSort(lst):  
  2.     lst = list(lst) #copy collection to list  
  3.     for passesLeft in range(len(lst)-1, 0, -1):  
  4.         for i in range(passesLeft):  
  5.             if lst[i] < lst[i + 1]:  
  6.                lst[i], lst[i + 1] = lst[i + 1], lst[i]  
  7.     return lst  
  8.  
  9.  
  10.  
  11. #//python/4547

回复 "python 冒泡法排序代码"

这儿你可以回复上面这条便签

captcha