直接对列表排序
num1 = int(input()) str1 = [] for i in range(num1): value = str(input()) str1.append(value) str1.sort() for value in str1: print(value)