Skip to main content

lexsort

Function lexsort 

Source
pub fn lexsort<T>(keys: &[&Array<T, Ix1>]) -> FerrayResult<Array<u64, Ix1>>
where T: Element + PartialOrd + Copy,
Expand description

Indirect stable sort using a sequence of keys.

keys is a list of 1-D arrays of the same length. The last key in the list is the primary sort key (matching NumPy’s numpy.lexsort convention); ties are broken by the second-to-last key, then the third-to-last, and so on. Returns a permutation idx such that keys[-1][idx] is non-decreasing.

Implementation notes: the underlying sort is sort_by (stable), applied once with a comparator that walks the keys from primary (last) to secondary (earlier). This avoids the multi-pass stable sort that NumPy historically used.

§Errors

  • FerrayError::InvalidValue if keys is empty or the keys have different lengths.