To sort the list according to length

examples/lists/sort_key.py
from __future__ import print_function

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