8000 introduce `list.sort()` but no details before · Issue #133881 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

introduce list.sort() but no details before #133881

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Yzi-Li opened this issue May 11, 2025 · 8 comments
Closed

introduce list.sort() but no details before #133881

Yzi-Li opened this issue May 11, 2025 · 8 comments
Assignees
Labels
docs Documentation in the Doc dir easy

Comments

@Yzi-Li
Copy link
Contributor
Yzi-Li commented May 11, 2025

Documentation

A example of lambda expressions introduces list.sort(), but there aren't details of list.sort() before.

>>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
>>> pairs.sort(key=lambda pair: pair[1])
>>> pairs
[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]

We shoud link more on lists after this example or in tutorial 3.1.3 lists.

Linked PRs

@Yzi-Li Yzi-Li added the docs Documentation in the Doc dir label May 11, 2025
@picnixz picnixz added the easy label May 11, 2025
@picnixz
Copy link
Member
picnixz commented May 11, 2025

We could write something like:

-Another use is to pass a small function as an argument:
+Another use is to pass a small function as an argument. For instance, :meth:`list.sort`
+takes a sorting key function *key* which can be a lambda function:

@Yzi-Li
Copy link
Contributor Author
Yzi-Li commented May 11, 2025

I agree with you.

@Yzi-Li
Copy link
Contributor Author
Yzi-Li commented May 11, 2025

Should I fix it or leave it for newcomers?

@picnixz
Copy link
Member
picnixz commented May 11, 2025

You can pick up the task if you want!

@Yzi-Li
Copy link
Contributor Author
Yzi-Li commented May 11, 2025

I would like to leave it.

@Shepard2154
Copy link
Contributor

I'm ready to take it on, I've already written the documentation for pip.

@sobolevn
Copy link
Member

@Shepard2154 thank you! please, feel free to ask any questions.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 17, 2025
…ression tutorial (pythonGH-133910)

(cherry picked from commit c1c9ad1)

Co-authored-by: Oleg Burnaev <51371645+Shepard2154@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 17, 2025
…ression tutorial (pythonGH-133910)

(cherry picked from commit c1c9ad1)

Co-authored-by: Oleg Burnaev <51371645+Shepard2154@users.noreply.github.com>
picnixz pushed a commit that referenced this issue May 17, 2025
…pression tutorial (GH-133910) (#134127)

gh-133881: add forward reference to `list.sort()` in lambda expression tutorial (GH-133910)
(cherry picked from commit c1c9ad1)

Co-authored-by: Oleg Burnaev <51371645+Shepard2154@users.noreply.github.com>
picnixz pushed a commit that referenced this issue May 17, 2025
…pression tutorial (GH-133910) (#134126)

gh-133881: add forward reference to `list.sort()` in lambda expression tutorial (GH-133910)
(cherry picked from commit c1c9ad1)

Co-authored-by: Oleg Burnaev <51371645+Shepard2154@users.noreply.github.com>
@picnixz
Copy link
Member
picnixz commented May 17, 2025

Thank you for the report & the fix.

@picnixz picnixz closed this as completed May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir easy
Projects
Status: Todo
Development

No branches or pull requests

4 participants
0