I'm currently new to python and got stuck at this question, can't seem to find the proper answer.
question:Given a list of words, return a list with the same words in order of length (longest to shortest), the second sort criteria should be alphabetical. Hint: you need think of two functions.
This is what I have so far:
def bylength(word1,word2):
return len(word2)-len(word1)
def sortlist(a):
a.sort(cmp=bylength)
return a
it sorts by length but I don't know how to apply the second criteria to this sort, which is by alphabetical descending.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…