nag_stable_sort (m01ctc) rearranges a vector of arbitrary type objects into ascending or descending order.
nag_stable_sort (m01ctc) sorts a set of
data objects of arbitrary type, which are stored in the elements of an array at intervals of length
stride. The function may be used to sort a column of a two-dimensional array. Either ascending or descending sort order may be specified.
A stable sort is one which preserves the order of distinct data items that compare equal. This function uses
nag_rank_sort (m01dsc),
nag_make_indices (m01zac) and
nag_reorder_vector (m01esc) in order to carry out a stable sort with the same specification as
nag_quicksort (m01csc). nag_stable_sort (m01ctc) will be faster than
nag_quicksort (m01csc) if the comparison function
compare is slow or the data items are large. Internally a large amount of workspace may be required compared with
nag_quicksort (m01csc).
- NE_2_INT_ARG_LT
-
On entry, while . These arguments must satisfy .
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- NE_BAD_PARAM
-
On entry, argument
order had an illegal value.
- NE_INT_ARG_GT
-
On entry, .
Constraint: , an implementation-dependent size that is printed in the error message.
On entry, .
Constraint: , an implementation-dependent size that is printed in the error message.
On entry, .
Constraint: , an implementation-dependent size that is printed in the error message.
- NE_INT_ARG_LT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
Not applicable.
nag_stable_sort (m01ctc) is not threaded in any implementation.
The example program reads a three column matrix of real numbers and sorts the first column into ascending order.