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 from each list element: ``key=str.lower``. The default value is ``None``
- (compare the elements directly).
+ key from each element in *iterable* (for example, ``key=str.lower``). The
+ default value is ``None`` (compare the elements directly).
*reverse* is a boolean value. If set to ``True``, then the list elements are
sorted as if each comparison were reversed.
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
- used to extract a comparison key from each element in the iterable:
- ``key=str.lower`` Equivalent to: ``sorted(iterable, key=key,
- reverse=True)[:n]``
+ used to extract a comparison key from each element in *iterable* (for example,
+ ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key,
+ reverse=True)[:n]``.
.. function:: nsmallest(n, iterable, key=None)
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
- used to extract a comparison key from each element in the iterable:
- ``key=str.lower`` Equivalent to: ``sorted(iterable, key=key)[:n]``
+ used to extract a comparison key from each element in *iterable* (for example,
+ ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:n]``.
The latter two functions perform best for smaller values of *n*. For larger