Select the n-th smallest element of a vector, using the ordering defined by
sort.
The result is equivalent to sort(x)(n).
n can also be a contiguous range, either ascending l:u
or descending u:-1:l, in which case a range of elements is returned.
If x is an array, nth_element operates along the dimension
defined by dim, or the first non-singleton dimension if dim is
not given.
Programming Note: nth_element encapsulates the C++ standard library
algorithms nth_element and partial_sort. On average, the complexity of the
operation is O(M*log(K)), where M = size (x, dim) and
K = length (n). This function is intended for cases where
the ratio K/M is small; otherwise, it may be better to use sort.
See also: sort, min, max.
Package: octave