# selection sort
def selection_sort(data):
for stand in range(len(data) - 1):
lowest = stand
for idx2 in range(stand + 1, len(data)):
if data[idx2] < data[lowest]:
lowest = idx2
data[stand], data[lowest] = data[lowest], data[stand]
return data
import random
data = random.sample(range(100), 10)
print(selection_sort(data))
댓글