naginterfaces.library.sort.charvec_​sort

naginterfaces.library.sort.charvec_sort(ch, m1, l1, l2, order)[source]

charvec_sort rearranges a vector of character data so that a specified substring is in ASCII or reverse ASCII order.

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

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/m01/m01ccf.html

Parameters
chstr, array-like, shape

Elements to of must contain character data 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.

l1int

Only the substring (:) of each element of is to be used in determining the sorted order.

l2int

Only the substring (:) of each element of is to be used in determining the sorted order.

orderstr, length 1

If , the values will be sorted into ASCII order.

If , into reverse ASCII order.

Returns
chstr, ndarray, shape

These values are rearranged into sorted order.

Raises
NagValueError
(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, has an illegal value: .

(errno )

On entry, .

Constraint: .

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

charvec_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.

Only the substring (:) of each element of the array is used to determine the sorted order, but the entire elements are rearranged into sorted order.

References

Sedgewick, R, 1978, Implementing Quicksort programs, Comm. ACM (21), 847–857

Singleton, R C, 1969, An efficient algorithm for sorting with minimal storage: Algorithm 347, Comm. ACM (12), 185–187