sort the elements according to their lengths : Sort « List « Python Tutorial






x = ['a', 'ab', 'ac', 'add', 'ae']
x.sort(key=len)
print x








7.24.Sort
7.24.1.The sort method is used to sort lists in place.
7.24.2.sort the elements according to their lengths
7.24.3.the list should be sorted in reverse:
7.24.4.Sorting a List
7.24.5.Key sort
7.24.6.Reverse sort