Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9f8a5b1a
Commit
9f8a5b1a
authored
Oct 28, 2014
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#22237: document that sorted() is guaranteed to be stable. Initial patch by Martin Panter.
parent
7876f72f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletion
+9
-1
Doc/library/functions.rst
Doc/library/functions.rst
+5
-0
Doc/library/heapq.rst
Doc/library/heapq.rst
+3
-1
Misc/ACKS
Misc/ACKS
+1
-0
No files found.
Doc/library/functions.rst
View file @
9f8a5b1a
...
...
@@ -1318,6 +1318,11 @@ available. They are listed here in alphabetical order.
each element only once. Use :func:`functools.cmp_to_key` to convert an
old-style *cmp* function to a *key* function.
The built-in :func:`sorted` function is guaranteed to be stable. A sort is
stable if it guarantees not to change the relative order of elements that
compare equal --- this is helpful for sorting in multiple passes (for
example, sort by department, then by salary grade).
For sorting examples and a brief sorting tutorial, see `Sorting HowTo
<http://wiki.python.org/moin/HowTo/Sorting/>`_\.
...
...
Doc/library/heapq.rst
View file @
9f8a5b1a
...
...
@@ -136,7 +136,6 @@ pushing all values onto a heap and then popping off the smallest values one at a
time::
>>> def heapsort(iterable):
... 'Equivalent to sorted(iterable)'
... h = []
... for value in iterable:
... heappush(h, value)
...
...
@@ -145,6 +144,9 @@ time::
>>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this
implementation is not stable.
Heap elements can be tuples. This is useful for assigning comparison values
(such as task priorities) alongside the main record being tracked::
...
...
Misc/ACKS
View file @
9f8a5b1a
...
...
@@ -1008,6 +1008,7 @@ Todd R. Palmer
Juan David Ibáñez Palomar
Jan Palus
Yongzhi Pan
Martin Panter
Mathias Panzenböck
M. Papillon
Peter Parente
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment