#rank #reorder

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

#4 in #rank

Download history 61/week @ 2022-11-27 181/week @ 2022-12-04 137/week @ 2022-12-11 88/week @ 2022-12-18 122/week @ 2022-12-25 70/week @ 2023-01-01 49/week @ 2023-01-08 63/week @ 2023-01-15 31/week @ 2023-01-22 108/week @ 2023-01-29 64/week @ 2023-02-05 64/week @ 2023-02-12 86/week @ 2023-02-19 53/week @ 2023-02-26 16/week @ 2023-03-05 10/week @ 2023-03-12

180 downloads per month
Used in kayak_ui

MIT/Apache

3KB

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