Commit 6bdb6f76 authored by Wolfgang Maier's avatar Wolfgang Maier Committed by Brian Curtin

fix dangling keyfunc examples in documentation of heapq and sorted (#1432)

* fix dangling mention of key=str.lower in heapq doc

* Fix dangling mention of keyfunc example for sorted()
parent 18fb1fb9
...@@ -1412,8 +1412,8 @@ are always available. They are listed here in alphabetical order. ...@@ -1412,8 +1412,8 @@ are always available. They are listed here in alphabetical order.
Has two optional arguments which must be specified as keyword arguments. Has two optional arguments which must be specified as keyword arguments.
*key* specifies a function of one argument that is used to extract a comparison *key* specifies a function of one argument that is used to extract a comparison
key from each list element: ``key=str.lower``. The default value is ``None`` key from each element in *iterable* (for example, ``key=str.lower``). The
(compare the elements directly). default value is ``None`` (compare the elements directly).
*reverse* is a boolean value. If set to ``True``, then the list elements are *reverse* is a boolean value. If set to ``True``, then the list elements are
sorted as if each comparison were reversed. sorted as if each comparison were reversed.
......
...@@ -112,17 +112,17 @@ The module also offers three general purpose functions based on heaps. ...@@ -112,17 +112,17 @@ The module also offers three general purpose functions based on heaps.
Return a list with the *n* largest elements from the dataset defined by Return a list with the *n* largest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is *iterable*. *key*, if provided, specifies a function of one argument that is
used to extract a comparison key from each element in the iterable: used to extract a comparison key from each element in *iterable* (for example,
``key=str.lower`` Equivalent to: ``sorted(iterable, key=key, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key,
reverse=True)[:n]`` reverse=True)[:n]``.
.. function:: nsmallest(n, iterable, key=None) .. function:: nsmallest(n, iterable, key=None)
Return a list with the *n* smallest elements from the dataset defined by Return a list with the *n* smallest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is *iterable*. *key*, if provided, specifies a function of one argument that is
used to extract a comparison key from each element in the iterable: used to extract a comparison key from each element in *iterable* (for example,
``key=str.lower`` Equivalent to: ``sorted(iterable, key=key)[:n]`` ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:n]``.
The latter two functions perform best for smaller values of *n*. For larger The latter two functions perform best for smaller values of *n*. For larger
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment