Skip to main content

partition

Function partition 

Source
pub fn partition<T>(
    a: &Array<T, Ix1>,
    kth: usize,
) -> FerrayResult<Array<T, Ix1>>
where T: Element + PartialOrd + Copy,
Expand description

Partial sort: rearrange elements so that a[kth] is the value that would be there in a sorted array, all elements before it are <=, and all elements after are >=. The relative order within the two halves is undefined.

Equivalent to numpy.partition(a, kth). Uses select_nth_unstable for O(n) average-case performance (#466).

ยงErrors

  • FerrayError::AxisOutOfBounds if kth >= a.size().