#order #rank

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

#11 in #rank

Download history 20/week @ 2023-11-30 37/week @ 2023-12-07 20/week @ 2023-12-14 24/week @ 2023-12-21 2/week @ 2023-12-28 3/week @ 2024-01-04 7/week @ 2024-01-11 4/week @ 2024-01-18 4/week @ 2024-02-01 26/week @ 2024-02-08 20/week @ 2024-02-15 45/week @ 2024-02-22 118/week @ 2024-02-29 36/week @ 2024-03-07 13/week @ 2024-03-14

215 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