How to sort a list of strings?

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

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

11条回答
  •  无人共我
    2020-11-22 11:51

    But how does this handle language specific sorting rules? Does it take locale into account?

    No, list.sort() is a generic sorting function. If you want to sort according to the Unicode rules, you'll have to define a custom sort key function. You can try using the pyuca module, but I don't know how complete it is.

提交回复
热议问题