【发布时间】:2012-04-12 07:22:43
【问题描述】:
可能重复:
how to sort by length of string followed by alphabetical order?
我想创建一个程序,按照从最短到最长字符数的顺序打印列表中的单词。例如:
["My", "turtle", "is", "old"]
会输出:
"My"
"is"
"old"
"turtle"
有什么简单的方法可以做到这一点吗?我到目前为止:
message = "My turtle is old"
message = message.split(" ")
【问题讨论】:
-
这完全代表“从最长到最短的字符数”吗?
-
how to sort by length of string followed by alphabetical order? 的可能重复项,甚至更准确的Sorting Python list based on the length of the string,我通过谷歌搜索“python 按长度排序”找到。
-
为什么标题从最短到最长,而问题是从最长到最短?下定决心:D
标签: python