#order #slice #rank #indices #array #auxiliary #reorder-index

reorder

Reorder a slice based on a slice of indices

5 stable releases

2.1.3 Mar 26, 2022
2.1.2 Jan 13, 2022
2.0.1 Dec 31, 2021
2.0.0 Apr 14, 2021
1.0.0 Dec 12, 2018

#3 in #auxiliary

Download history 5/week @ 2024-11-13 4/week @ 2024-11-20 6/week @ 2024-12-04 58/week @ 2024-12-11 10/week @ 2024-12-18 6/week @ 2025-01-08 27/week @ 2025-01-15 10/week @ 2025-01-22 15/week @ 2025-01-29

58 downloads per month
Used in kayak_ui

MIT/Apache

4KB

Simple crate that will reorder a slice based on a slice of indices without an auxiliary array.

Check it out on crates.io and github and docs.rs.

Example

fn main() {
    
    let (mut arr, mut ind, res) = (
        [50, 40, 70, 60, 90, 10],
        [03, 00, 04, 01, 02, 05],
        [40, 60, 90, 50, 70, 10],
    );
    reorder_index(&mut arr, &mut ind);
    assert_eq!(arr, res);
}

lib.rs:

Simple crate that will reorder a slice based on a slice of indices without an auxiliary array. See https://www.geeksforgeeks.org/reorder-a-array-according-to-given-indexes/

No runtime deps