首页 > 代码库 > python选择排序

python选择排序

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]