python 选择排序算法实现

时间:2022-02-05 22:08:08
#coding=utf-8

def select_sort(arr):
        tmp = []
        while len(arr) > 0:
                t = min(arr)
                arr.remove(t)
                # tmp.insert(0,t)
                tmp.append(t)
        return tmp

li = [2, 8, 5, 4, 1, 5]

li = select_sort(li)

print li