📜  排序迭代 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:47.084000             🧑  作者: Mango

代码示例1
basket = ['pear', 'banana', 'orange', 'pear', 'apple']

# use sorted to return a new sorted list before iterating
for fruit in sorted(basket):
  print(fruit)

# =>
# apple
# banana
# orange
# pear
# pear