# naginterfaces.library.sort.realvec_​sort¶

naginterfaces.library.sort.realvec_sort(rv, m1, order)[source]

realvec_sort rearranges a vector of float numbers into ascending or descending order.

For full information please refer to the NAG Library document for m01ca

https://www.nag.com/numeric/nl/nagdoc_29/flhtml/m01/m01caf.html

Parameters
rvfloat, array-like, shape

Elements to of must contain float values to be sorted.

m1int

Note: this argument represents an array index; the value you supply must be base-1 for compatibility with the NAG Engine.

The index of the first element of to be sorted.

orderstr, length 1

If , the values will be sorted into ascending (i.e., nondecreasing) order.

If , into descending order.

Returns
rvfloat, ndarray, shape

These values are rearranged into sorted order.

Raises
NagValueError
(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, has an illegal value: .

Notes

realvec_sort is based on Singleton’s implementation of the ‘median-of-three’ Quicksort algorithm (see Singleton (1969)), but with two additional modifications. First, small subfiles are sorted by an insertion sort on a separate final pass (see Sedgewick (1978)). Second, if a subfile is partitioned into two very unbalanced subfiles, the larger of them is flagged for special treatment: before it is partitioned, its end points are swapped with two random points within it; this makes the worst case behaviour extremely unlikely.