-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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
Conversation
@Natr1x As long as we're being excruciatingly explicit, should we note that "ascending" here causes ...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. |
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. |
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. |
r? libs-api |
r? libs-api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@bors r+ rollup |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#140526 (docs: Specify that common sort functions sort in an ascending direction) - rust-lang#141230 (std: fix doctest and explain for `as_slices` and `as_mut_slices` in `VecDeque`) - rust-lang#141341 (limit impls of `VaArgSafe` to just types that are actually safe) - rust-lang#141347 (incorrectly prefer builtin `dyn` impls :3) - rust-lang#141351 (Move -Zcrate-attr injection to just after crate root parsing) - rust-lang#141356 (lower bodies' params to thir before the body's value) - rust-lang#141357 (`unpretty=thir-tree`: don't require the final expr to be the body's value) - rust-lang#141363 (Document why we allow escaping bound vars in LTA norm) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#140526 - Natr1x:sort-direction-documentation, r=dtolnay docs: Specify that common sort functions sort in an ascending direction From [forum discussion](https://users.rust-lang.org/t/is-there-a-way-to-sort-a-slice-in-specifically-ascending-or-descending-order/128998?u=natr1x) 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.
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.