Код:
def selection_sort(A):
for i in range(len(A)):
lowest_value_index = i
for j in range(i + 1, len(A)):
if A[j] < A[lowest_value_index]:
lowest_value_index = j
A[i], A[lowest_value_index] = A[lowest_value_index], A[i]
f = open("input.txt", "r")
line = f.readline()
theList = []
while line:
theList.append(int(line))
line = f.readline()
f = open("output.txt", 'w')
f.close()
print(theList)
print(selection_sort(theList))
Выводит:
[2, 3, 4, 1, 5, 3, 6, 7, 8, 7, 5, 34, 5, 6, 45, 7457, 54, 74, 56, 456, 45, 745, 7, 34, 56, 54, 7, 5687, 54, 67, 5, 8754, 6754, 67, 5]
None