sort function accepts returning value of a lambda as the key parameter to sort the list using it. So what's happening here is that the lambda function iterates over the list and passes pair[1] of each member of the list which is the textual representation of the number and because these values are a string, the sort function sorts them in alphabetical order. First (f)our, then (o)ne and so on.