Sort an array of pointers to access an array in ascending order

The
routine uses the QUICKSORT algorithm to permute an array of pointers so that they access an
associated array of values in ascending order. The “median of three” modification is included to
reduce the likelihood of encountering the worst-case behaviour of QUICKSORT.

The routine exists for types REAL (x=R), DOUBLE PRECISION (x=D), and INTEGER (x=I).

CALL PDA_QSIAx( EL, X, IP )

The number of
elements of X to sort.

The array to be sorted.

The indices of the elements of X in sorted order (i.e. IP( 1 ) gives the index into X of the
lowest value).

Sedgwick, R., 1988, Algorithms (Addison-Wesley).

If N elements are to be sorted, the average time goes as N*ln(N). The worst-case time
goes as N**2.

Copyright (C) 1992 Science & Engineering Research Council