External Publication
Visit Post

`<[T]>::sort_by_index` and `<[T]>::sort_by_key_and_index`

Rust Internals [Unofficial] April 14, 2026
Source

Maybe some API may be composed in order to sort multiple slices with one leader? Structure of arrays basically.

First thing coming to mind is something like

let slice_a;
let slice_b;

slice_a.manual_sort_unstable(|slice, i, j| {
    mem::swap(&mut slice[i], &mut slice[j]);
    mem::swap(&mut slice_b[i], &mut slice_b[j]);
});

Discussion in the ATmosphere

Loading comments...