Order by word lenghts X30120


Statement
 

pdf   zip

thehtml

Write a function length_sorted(f) that provided a list of words f returns a list g with the very same words of f. Words in g must appear in increasing lengths. Words of the same length must appear in alpabetical order. All characters in words are lowercase letters.

Sample session
>>> length_sorted(['z', 'ping', 'king', 'doork', 'koong', 'doong', 'x'])
['x', 'z', 'king', 'ping', 'doong', 'doork', 'koong']
>>> length_sorted(['winter', 'winner', 'counter', 'mother', 'table'])
['table', 'mother', 'winner', 'winter', 'counter']
>>> length_sorted(['self', 'made', 'man'])
['man', 'made', 'self']
>>> length_sorted(['z', 'y', 'x', ''])
['', 'x', 'y', 'z']
Information
Author
Language
English
Official solutions
Python
User solutions
Python