pub trait ArraySortExt: Arraywhere
    <Self as Array>::Item: PartialOrd,
{ fn get_sorted_indices(&self) -> Vec<usize> { ... } }
Expand description

Get sorted indices from the current Array

Provided Methods§

Get indices of original items in a sorted array, which can be directly used in ArrayBuilderPickExt.

For example, [1, 7, 3, 9, 5] will have a sorted indices of [0, 2, 4, 1, 3].

Note that None is the smallest item, and will be put before any other items.

use risinglight::array::*;

let array = I32Array::from_iter([Some(1), Some(7), Some(3), Some(9), Some(5), None, None]);
let indices = array.get_sorted_indices();
assert_eq!(indices[2..], [0, 2, 4, 1, 3]);

let mut builder = I32ArrayBuilder::with_capacity(10);
builder.pick_from(&array, &indices);
assert_eq!(
    builder.finish().to_vec(),
    [None, None, Some(1), Some(3), Some(5), Some(7), Some(9)]
);

Implementors§