题解 | 字符串排序
字符串排序
https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
n=int(input())
arr=[]
for i in range(n):
arr.append(input())
arr.sort()
for i in range(n):
print(arr[i])
直接用sort()即可,对于字符串类型的列表,sort()方法默认就是按字典序升序的
字符串排序
https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
n=int(input())
arr=[]
for i in range(n):
arr.append(input())
arr.sort()
for i in range(n):
print(arr[i])
直接用sort()即可,对于字符串类型的列表,sort()方法默认就是按字典序升序的
相关推荐
飞屋一号:给各ai拉个群,让他们给你打黑工