[issue7257] Improve documentation of list.sort and sorted()
Ole Laursen
report at bugs.python.org
Tue Nov 3 20:22:00 CET 2009
Ole Laursen <olau at iola.dk> added the comment:
If you think it's too long, here's a shorter version:
Sorts sequence in place with a fast stable sort, returning None. key is
a function for extracting a comparison key from each element, e.g.
key=lambda x: x['name'] or key=str.lower. reverse=True reverses the
result order.
a = [1, 3, 2]
a.sort() # a is now [1, 2, 3]
Use the "sorted()" built-in function if you need to preserve the
original list.
Is this better? You could whack the last comment about sorted and/or the
example, then it's about the same length as the other built-in
docstrings (e.g. zip, reduce, getattr).
----------
nosy: -rhettinger
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7257>
_______________________________________
More information about the Python-bugs-list
mailing list