CXML
isortq, ssortq, dsortq
Sort the elements of a vector
FORMAT
{I,S,D}SORTQ
( order, n, x, incx )
Arguments
order character*1
On entry, order specifies the operation to be performed
as follows:
If order = 'A' or 'a', x is sorted in ascending
sequence
If order = 'D' or 'd', x is sorted in descending
sequence
On exit, order is unchanged.
n integer*4
On entry, the length of vector x.
On exit, n is unchanged.
x integer*4 | real*4 | real*8
On entry, a length n vector of data to be sorted.
On exit, x is overwritten by a length n vector of
sorted data.
incx integer*4
On entry, incx specifies the distance between elements
of vector x. incx must be positive.
On exit, incx is unchanged.
Description
The _SORTQ routines sort a vector of data using the quicksort algorithm.
Data is sorted in ascending order if order is 'A' or 'a' and in descending
order if order is 'D' or 'd'. The quicksort algorithm is implemented by
recursing until the partition size is less than sixteen. At that point a
simple replacement sort is used to sort the elements of the partition.
Example
REAL*4 DATA( 100 )
N = 100
CALL SSORTQ( 'A',N,DATA,1 )
This FORTRAN code sorts a 100 element single real vector.
CXML Home Page Index of CXML Routines