`<[T]>::sort_by_index` and `<[T]>::sort_by_key_and_index`
Rust Internals [Unofficial]
April 16, 2026
The O(N2) way is what get_disjoint_mut does, comparing every index against duplicates (and in range), which as you say is also a permutation if N == len(). But of course the assumption in that case is that N is usually small.
Discussion in the ATmosphere