How to sort a list of strings?

后端 未结 11 775
孤独总比滥情好
孤独总比滥情好 2020-11-22 11:22

What is the best way of creating an alphabetically sorted list in Python?

11条回答
  •  孤街浪徒
    2020-11-22 11:38

    It is also worth noting the sorted() function:

    for x in sorted(list):
        print x
    

    This returns a new, sorted version of a list without changing the original list.

提交回复
热议问题