Skip to content

Use sort_unstable to sort primitive types #80483

Open

Description

When sorting primitive types, without a sort_by function, sort and sort_unstable produce the same output (because the "identical elements" are themselves indistinguishable).

This change was done by hand ( #76541 ), and clippy will recommend changing sort to sort_unstable on primitive types.

However, if it is so useful it feels like it should be easy to do within the standard library itself, if there is a trait (or a trait was added) for primitive types.

This feel preferably to the current situation, where clippy tells users to change it, as then (see #76541 for example ), users have to keep adding comments to remind themselves that the sort_unstable is actually stable in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-sliceArea: `[T]`I-slowIssue: Problems and improvements with respect to performance of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions