📜  例如:python 代码示例

📅  最后修改于: 2022-03-11 14:47:22.338000             🧑  作者: Mango

代码示例1
def insertion_sort(data):
    for i in range(0, len(data)):
        insert_val = data[i]
        hole_pos = i

        while hole_pos > 0 and insert_val < data[hole_pos - 1]:
            data[hole_pos] = data[hole_pos - 1]
            hole_pos = hole_pos - 1

        data[hole_pos] = insert_val