Skip to content

docs: Specify that common sort functions sort in an ascending direction #140526

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Natr1x
Copy link

@Natr1x Natr1x commented Apr 30, 2025

From forum discussion it seems like the sorting direction can be expected to always be ascending (in terms of cmp::Ordering).

If this is the case then it would be nice to have this stated in the documentation.

@rustbot
Copy link
Collaborator

rustbot commented Apr 30, 2025

r? @joboet

rustbot has assigned @joboet.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 30, 2025
@workingjubilee
Copy link
Member

workingjubilee commented Apr 30, 2025

@Natr1x As long as we're being excruciatingly explicit, should we note that "ascending" here causes slice::first to be the least and slice::last to be the greatest according to the Ordering? Or that the index order of values also compares like their comparison order, if you prefer (the least index, 0, is now the least value, et cetera).

...I say this because I have gotten confused before when "ascending" and "descending" flew around in a conversation that involved multi-part or "reversed" keys such that both "directions" lacked an obvious meaning. For bonus fun, at that point in a conversation, sometimes people will talk about the sorted ordering being "descending" when they have used such a sorting function to sort things into the ascending order of a reversed key.

@Natr1x
Copy link
Author

Natr1x commented May 1, 2025

@workingjubilee

I considered it. But I think the examples already explain this, and the extra clutter may just make it harder to read and thus more confusing.

The biggest reason I wanted to add this was to clarify that the order direction is consistent and expected to stay the same.

@workingjubilee
Copy link
Member

cool! yeah, "the examples already cover that" seems like a good reason for allowing the code to be the extra explanation since the code is... extra explanation. I still wonder if we should talk more about it, but we can explore that in other ways another day.

seems fine to me then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants