SSORT(3)

SYNOPSIS
SUBROUTINE SSORT (X, Y, N, KFLAG)

NAME
ssort - Sort an array and optionally make the same interchanges in an auxiliary array. The array may be sorted in increasing or decreasing order. A slightly modified QUICKSORT algorithm is used.

LIBRARY
SLATEC

CATEGORY
N6A2B

TYPE
SINGLE PRECISION (SSORT-S, DSORT-D, ISORT-I)

KEYWORDS
SINGLETON QUICKSORT, SORT, SORTING

AUTHOR
Jones, R. E., (SNLA) Wisniewski, J. A., (SNLA)

DESCRIPTION
SSORT sorts array X and optionally makes the same interchanges in array Y. The array X may be sorted in increasing order or decreasing order. A slightly modified quicksort algorithm is used. Description of Parameters X - array of values to be sorted (usually abscissas) Y - array to be (optionally) carried along N - number of values in array X to be sorted KFLAG - control parameter = 2 means sort X in increasing order and carry Y along. = 1 means sort X in increasing order (ignoring Y) = -1 means sort X in decreasing order (ignoring Y) = -2 means sort X in decreasing order and carry Y along.

REFERENCES
R. C. Singleton, Algorithm 347, An efficient algorithm for sorting with minimal storage, Communications of the ACM, 12, 3 (1969), pp. 185-187.

ROUTINES CALLED
XERMSG

REVISION HISTORY (YYMMDD)
761101 DATE WRITTEN
761118 Modified to use the Singleton quicksort algorithm. (JAW)
890531 Changed all specific intrinsics to generic. (WRB)
890831 Modified array declarations. (WRB)
891009 Removed unreferenced statement labels. (WRB)
891024 Changed category. (WRB)
891024 REVISION DATE from Version 3.2
891214 Prologue converted to Version 4.0 format. (BAB)
900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
901012 Declared all variables; changed X,Y to SX,SY. (M. McClain)
920501 Reformatted the REFERENCES section. (DWL, WRB)
920519 Clarified error messages. (DWL)
920801 Declarations section rebuilt and code restructured to use IF-THEN-ELSE-ENDIF. (RWC, WRB)