For some things it's trivial to sort them, like real numbers, and English words.
Other things are harder to sort, like complex numbers, Chinese words, cars...
Or there may be multiple ways. I.e. people can be sorted by name, age, height...
That's why the sort function let's you choose what to sort by. You can pass a small function that converts the object (i.e. person) to the thing to sort (i.e. age).
The syntax
lambda pair: pair[1]
means
def f(pair):
return pair[1]