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).
Not applicable.
Not applicable.
The example program reads a three column matrix of real numbers and sorts the first column into ascending order.