Order by word lenghts X94202


Statement
 

pdf   zip

html

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
ProAl
Language
English
Official solutions
Python
User solutions
Python