Repository: rust
Issue: Tracking Issue for unstable sorting in const context
Labels: T-libs-api,C-tracking-issue

<!--
Thank you for creating a tracking issue!

Tracking issues are for tracking a feature from implementation to stabilization.

Make sure to include the relevant RFC for the feature if it has one.

If the new feature is small, it may be fine to skip the RFC process. In that
case, you can use use `issue = "none"` in your initial implementation PR. The
reviewer will ask you to open a tracking issue if they agree your feature can be
added without an RFC.
-->

Feature gate: `#![feature(const_sort)]`

This is a tracking issue for const `slice::sort_unstable` and `sort_internals`.

<!--
Include a short description of the feature.
-->

### Public API

<!--
For most library features, it'd be useful to include a summarized version of the public API.
(E.g. just the public function signatures without their doc comments or implementation.)
-->

```rust
// core::slice

pub const fn heapsort<T, F>(v: &mut [T], mut is_less: F)
where
    F: ~const FnMut(&T, &T) -> bool + ~const Destruct;

pub const fn sort_unstable(&mut self)
    where
        T: ~const Ord;

 pub const fn sort_unstable_by<F>(&mut self, mut compare: F)
    where
        F: ~const FnMut(&T, &T) -> Ordering + ~const Destruct;

pub const fn sort_unstable_by_key<K, F>(&mut self, mut f: F)
    where
        F: ~const FnMut(&T) -> K + ~const Destruct,
        K: ~const Ord + ~const Destruct;

pub const fn select_nth_unstable(&mut self, index: usize) -> (&mut [T], &mut T, &mut [T])
    where
        T: ~const Ord;

 pub const fn select_nth_unstable_by<F>(
        &mut self,
        index: usize,
        mut compare: F,
    ) -> (&mut [T], &mut T, &mut [T])
    where
        F: ~const FnMut(&T, &T) -> Ordering + ~const Destruct;

pub const fn select_nth_unstable_by_key<K, F>(
        &mut self,
        index: usize,
        mut f: F,
    ) -> (&mut [T], &mut T, &mut [T])
    where
        F: ~const FnMut(&T) -> K + ~const Destruct,
        K: ~const Ord + ~const Destruct;

pub const fn is_sorted(&self) -> bool
    where
        T: ~const PartialOrd;

pub const fn is_sorted_by<F>(&self, mut compare: F) -> bool
    where
        F: ~const FnMut(&T, &T) -> Option<Ordering> + ~const Destruct;

pub const fn is_sorted_by_key<F, K>(&self, mut f: F) -> bool
    where
        F: ~const FnMut(&T) -> K + ~const Destruct,
        K: ~const PartialOrd + ~const Destruct;
```

`slice::sort[_by[_key]]` would need allocations in const context to be implemented. #79597

### Steps / History

<!--
For larger features, more steps might be involved.
If the feature is changed later, please add those PRs here as well.
-->

- [ ] Implementation: #102279
- [ ] Final comment period (FCP)[^1]
- [ ] Stabilization PR

<!--
Once the feature has gone through a few release cycles and there are no
unresolved questions left, the feature might be ready for stabilization.

If this feature didn't go through the RFC process, a final comment period
(FCP) is always needed before stabilization. This works as follows:

A library API team member can kick off the stabilization process, at which point
the rfcbot will ask all the team members to verify they agree with
stabilization. Once enough members agree and there are no concerns, the final
comment period begins: this issue will be marked as such and will be listed
in the next This Week in Rust newsletter. If no blocking concerns are raised in
that period of 10 days, a stabilzation PR can be opened by anyone.
-->

### Unresolved Questions

<!--
Include any open questions that need to be answered before the feature can be
stabilised. If multiple (unrelated) big questions come up, it can be a good idea
to open a separate issue for each, to make it easier to keep track of the
discussions.

It's useful to link any relevant discussions and conclusions (whether on GitHub,
Zulip, or the internals forum) here.
-->

- See #102279

[^1]: https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html