python实现选择排序

def insert_sort(lists):
    count = len(lists)
    for i in range(1,count):
        key = lists[i]
        j = i-1
        while j>=0:
            if lists[j]>key:
                lists[j+1] = lists[j]
                lists[j] = key
            j-=1
    return lists
lists= [2,5,1,3,8,7,4,6,9]
print(insert_sort(lists))
阅读更多

没有更多推荐了,返回首页