gh-133881: add forward reference to list.sort() in lambda expression tutorial (#133910)

This commit is contained in:
Oleg Burnaev 2025-05-17 10:59:37 +03:00 committed by GitHub
parent faac627e47
commit c1c9ad1d5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -999,7 +999,8 @@ scope::
43 43
The above example uses a lambda expression to return a function. Another use The above example uses a lambda expression to return a function. Another use
is to pass a small function as an argument:: is to pass a small function as an argument. For instance, :meth:`list.sort`
takes a sorting key function *key* which can be a lambda function::
>>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')] >>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
>>> pairs.sort(key=lambda pair: pair[1]) >>> pairs.sort(key=lambda pair: pair[1])