python冒泡排序

def bubblesort(nums):

for i in  range(len(nums)-1):

  for j in range(len(nums)-i-1):

    if nums[j]>nums[j+1]:

      nums[j],nums[j+1]=nums[j+1],nums[j]

return nums

nums=[3,123,34,43,0,3,6,8]

print(bubblesort(nums))

posted @ 2017-02-06 23:04  张利宁的杂货铺  阅读(211)  评论(0编辑  收藏  举报