Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Doc: Clarify sorted() returns new list in sorting howto#144272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletionsDoc/howto/sorting.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,11 +17,16 @@ Sorting Basics
==============

A simple ascending sort is very easy: just call the :func:`sorted` function. It
returns a new sorted list:
returns a new sorted list and does not modify the original.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

IMO, it's useless. HOWTO already very clear here and sorted docs also:

Return a new sorted list from the items in iterable.


If you do not store or otherwise use the return value, the sorted result is
lost:
Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's also redundant, given above sentence.

No need to explain every basic language feature in the HOWTO. We have the Tutorial for this.


.. doctest::

>>> sorted([5, 2, 3, 1, 4])
>>> integers = [5, 2, 3, 1, 4]
>>> sorted_integers = sorted(integers)
>>> sorted_integers
[1, 2, 3, 4, 5]

You can also use the :meth:`list.sort` method. It modifies the list
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp