To sort the list according to length using sorted

examples/lists/sorted_key.py
from __future__ import print_function

animals = ['chicken', 'cow', 'snail', 'elephant']
print(sorted(animals))          # ['chicken', 'cow', 'elephant', 'snail']
srt = sorted(animals, key=len)
print(srt)                      # ['cow', 'snail', 'chicken', 'elephant']