]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39374: Updated sorting documentation (GH-18177)
authorJuhana Jauhiainen <juhana.jauhiainen@gmail.com>
Sat, 25 Jan 2020 22:18:58 +0000 (00:18 +0200)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>
Sat, 25 Jan 2020 22:18:58 +0000 (14:18 -0800)
Doc/howto/sorting.rst

index 1d6d5c45b4d9f9fcf1607536cb1d23969e601b80..a8efe65353d6e14b7aa0cb5d4ad7b4aff5245043 100644 (file)
@@ -43,16 +43,18 @@ Key Functions
 =============
 
 Both :meth:`list.sort` and :func:`sorted` have a *key* parameter to specify a
-function to be called on each list element prior to making comparisons.
+function (or other callable) to be called on each list element prior to making
+comparisons.
 
 For example, here's a case-insensitive string comparison:
 
     >>> sorted("This is a test string from Andrew".split(), key=str.lower)
     ['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']
 
-The value of the *key* parameter should be a function that takes a single argument
-and returns a key to use for sorting purposes. This technique is fast because
-the key function is called exactly once for each input record.
+The value of the *key* parameter should be a function (or other callable) that
+takes a single argument and returns a key to use for sorting purposes. This
+technique is fast because the key function is called exactly once for each
+input record.
 
 A common pattern is to sort complex objects using some of the object's indices
 as keys. For example: