这里的任何一个人能不能请用这个代码举例,如果可能的话,这个代码在做什么?你知道吗
def sort_by_length(words):
t = []
for word in words:
t.append((len(word), word))
t.sort(reverse=True)
res = []
for length, word in t:
res.append(word)
return res
反向的意思是什么?反向是什么?我确实明白人们用什么方法来表示,而不是用反向来表示什么
Tags:
按长度对单词排序
http://ideone.com/jRzatV
它返回一个单词列表,从最长到最短排序,然后从z到a
你也可以做同样的事
从最长到最短,从a到z排序可能更有意义
相关问题 更多 >
编程相关推荐