HP MLIB User's Guide Vol. 2 7th Ed.

Chapter 7 Miscellaneous Routines 621
Sort array SSORT/DSORT/ISORT
n Number of elements of vector x to be sorted. If n 1,
the subprograms do not reference x.
x Array of length lenx = (n1)×|incx|+1 containing the
data to be sorted.
incx Increment for the array x. x is stored forward in array
x with increment |incx|; that is, x
i
is stored in
x((i1)×|incx|+1).
Use incx = 1 if the vector x is stored contiguously in
array x, that is, if x
i
is stored in x(i). Refer to “BLAS
Indexing Conventions” in Chapter 2.
Output x If n 0 or if order is not ’A’, ’a’, ’D’, or ’d’, then x is
unchanged. Otherwise, the sorted result replaces the
input.
Notes Actual character arguments in a subroutine call may be longer than
corresponding dummy arguments. Therefore, readability of the CALL
statement may be improved by coding the order argument as ascending or
descending. Refer to “Example 2” on page 621.
Example 1 Sort the elements of a REAL*4 vector x into ascending order, where x is a vector
100 elements long stored in a one-dimensional array X of dimension 200.
CHARACTER*(*) ORDER
INTEGER*4 N,INCX
REAL*4 X(200)
ORDER = ’A’
N = 100
INCX = 1
CALL SSORT (ORDER,N,X,INCX)
Example 2 Sort the elements of a REAL*8 vector x into descending order, where x is a
vector 100 elements long stored in a one-dimensional array X of dimension 200.
CHARACTER*(*) ORDER
INTEGER*4 N,INCX
REAL*8 X(200)
CALL DSORT (’DESCENDING’,100,X,1)