Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

ISORTQ(3dxml)  —  Subroutines

Name

isortq, ssortq, dsortq − Sort the elements of a vector

FORMAT

{I,S,D}SORTQ ( order, n, x, incx )

Arguments

ordercharacter∗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. 

ninteger∗4
On entry, the length of vector x. 
On exit, n is unchanged. 

xinteger∗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. 

incxinteger∗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.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026