def select_sort(list): for i in range(len(list)): position = i for j in range(i,len(list)): if list[position] > list[j]: position = j temp = list[i] list[i] = list[position] list[position] = temp
list = [4,4,11,23,4,5,7,9,0,111]
select_sort(list)
list
[0, 4, 4, 4, 5, 7, 9, 11, 23, 111]
python选择排序
时间: 2024-10-05 18:54:24