How to sort a list of strings?

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

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

11条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 11:31

    It is simple: https://trinket.io/library/trinkets/5db81676e4

    scores = '54 - Alice,35 - Bob,27 - Carol,27 - Chuck,05 - Craig,30 - Dan,27 - Erin,77 - Eve,14 - Fay,20 - Frank,48 - Grace,61 - Heidi,03 - Judy,28 - Mallory,05 - Olivia,44 - Oscar,34 - Peggy,30 - Sybil,82 - Trent,75 - Trudy,92 - Victor,37 - Walter'
    

    scores = scores.split(',') for x in sorted(scores): print(x)

提交回复
热议问题