冒泡排序--python

def bubbleSort(nums):
    i = len(nums) - 1
    while (i > 0):
            last_index = 0
            for j in range(i):
                     if nums[j] > nums[j+1]:
                            nums[j],nums[j+1] = nums[j+1],nums[j]
                            last_index = j
             i = last_index
    return nums

 

posted @ 2017-09-01 23:18  715776681  阅读(150)  评论(0编辑  收藏  举报