Mega Code Archive
Categories
/
Python Tutorial
/
List
Sort the elements according to their lengths
x = ['a', 'ab', 'ac', 'add', 'ae'] x.sort(key=len) print x