Let l again be a list of data type Ƭ, on which we define an order:
l = [l1, l2 ... ln]
Let f be a function with parameters of data type Ƭ. f is a mapping into a data type, where there is an ordering in Python available.
f can be used for sorting with the key
The list [f(l1), f(l2)... f(ln)] is sorted and the original list l will be sorted correspondingly, i.e. neighbouring list elements li and li+1 will be swapped if f(li) > f(li+1).
The correct Python call is:
l.sort(key=f)