Purpose
Sort
a list or an array or (a subset of) the indices of an array.
Synopsis
procedure qsort(sense:boolean, lvals:list of integer)
procedure qsort(sense:boolean, lvals:list of real)
procedure qsort(sense:boolean, lvals:list of string)
procedure qsort(sense:boolean, vals:array of integer)
procedure qsort(sense:boolean, vals:array of real)
procedure qsort(sense:boolean, vals:array of string)
procedure qsort(sense:boolean, vals:array of integer, ndx:array)
procedure qsort(sense:boolean, vals:array of real, ndx:array)
procedure qsort(sense:boolean, vals:array of string, ndx:array)
procedure qsort(sense:boolean, vals:array of integer, ndx:array, sel:set)
procedure qsort(sense:boolean, vals:array of real, ndx:array, sel:set)
procedure qsort(sense:boolean, vals:array of string, ndx:array, sel:set)
Arguments
sense
|
Sense of the sorting:
|
lvals
|
List to be sorted
|
vals
|
One-dimensional array to be sorted
|
ndx
|
One-dimensional array of the same type and size as the
indexing set of vals
|
sel
|
Subset of the indexing set of vals
|
Example
The following example sorts an array of real numbers:
declarations
ar: array(1..10) of real
end-declarations
ar:: [1.2, -3, -8, 10.5, 4, 7, 2.9, -1, 0, 5]
qsort(true, ar)
writeln("Sorted array: ", ar)
Further information
1. In the first three versions of the procedure (with two arguments, sense and vals) the input array
vals is overwritten by the resulting sorted array.
2. When an index set ndx is provided, the resulting sorted
array is returned in the argument ndx in the form of its
sorted index set. If a selection set sel of indices
is provided, only the specified indices are processed.
If you have any comments or suggestions about these pages,
please send mail to docs@dashoptimization.com.