记录python题(1) 编写函数,模拟内置函数sorted()

def mone_sorted(itera):
    new_itera = []
    while itera:
        min_value = min(itera)
        new_itera.append(min_value)
        itera.remove(min_value)
  return new_itera if __name__ == "__main__": lst = [2, 3, 1, 5, 4] print(mone_sorted(lst))

函数内部使用了选择排序的思想

猜你喜欢

转载自www.cnblogs.com/xiaozx/p/10577655.html
今日推荐