码迷,mamicode.com
首页 > 编程语言 > 详细

python 冒泡排序

时间:2018-09-22 10:38:40      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:pytho   sort   print   range   冒泡排序   highlight   count   python   list   

def bubble_sort(blist):

    count = len(blist)

    for i in range(0, count):

        for j in range(i + 1, count):

            if blist[i] > blist[j]:

                blist[i], blist[j] = blist[j], blist[i]

    return blist

 

blist = bubble_sort([4,5,6,7,3,2,6,9,8])

print(blist)

  

python 冒泡排序

标签:pytho   sort   print   range   冒泡排序   highlight   count   python   list   

原文地址:https://www.cnblogs.com/sea-stream/p/9689044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!