Skip to main content

sort_multi

Function sort_multi 

Source
pub fn sort_multi<B: Backend, T: Element>(
    operands: &[Array<B, T>],
    dimension: usize,
    num_keys: usize,
) -> Vec<Array<B, T>>
Expand description

Sorts operands (of the same shape and element type) along dimension, stably and lexicographically by the first num_keys of them, and permutes the others in the same way (lax.sort with several operands and num_keys, as jnp.lexsort uses it).

§Examples

use ruxla_core::{Array, Native, lax};

let a = Array::<Native, i32>::from_vec(vec![1, 0, 1, 0], [4]);
let b = Array::<Native, i32>::from_vec(vec![0, 1, 0, 0], [4]);
let i = Array::<Native, i32>::from_vec(vec![0, 1, 2, 3], [4]);
let out = lax::sort_multi(&[a, b, i], 0, 2);
assert_eq!(out[2].to_vec(), [3, 1, 0, 2]);

§Panics

Panics if num_keys is zero or more than the number of operands.