import random
import pretty_errors
def selectSort(data):
length = len(data)
border = length - 1
for i in range(length):
max_num = 0
for j in range(border):
max_num = (j if (data[max_num] < data[j]) else max_num)
# if data[max_num] < data[j]:
# max_num = j
data[max_num], data[border] = data[border], data[max_num]
border = border - 1
#打印输出
def printf(data_p, state):
for i in state:
print(i, end = '')
print(':')
for i in data_p:
print(i, end = ' ')
print('\n')
def main():
data = []
for i in range(30):
data.append(random.randint(-1000,1000))
printf(data, "raw data")
selectSort(data)
printf(data, "sorted data")
if __name__ == '__main__':
main()