Optional Argument. DIM
Description. Sort by ascending value.
Class. Transformational function.
ARRAY must be of type integer, real, or character. It must not be scalar.
DIM (optional) must be scalar and of type integer
with a value in
the range 1 < DIM < n,
where n is the rank of ARRAY.
The corresponding actual argument must not be
an optional dummy argument.
Result Type, Type Parameter, and Shape. The result has the same
shape, type, and type parameter as ARRAY.
Case (i): The result of SORT_UP(ARRAY), when ARRAY is one-dimensional, is a vector of the same shape as ARRAY, containing the same elements (with the same number of instances) but sorted in ascending element order. The collating sequence for an array of type CHARACTER is that used by the Fortran intrinsic functions, namely ASCII.
Case (ii): The result of SORT_UP(ARRAY) for a multi-dimensional ARRAY is the result that would be obtained by reshaping ARRAY to a rank-one array V using array element order, sorting that rank-one array in ascending order, as in Case(i), and finally restoring the result to the original shape. That is, it gives the same result as RESHAPE( SORT_UP(V), SHAPE = SHAPE(ARRAY) ), where V = RESHAPE( ARRAY, SHAPE = (/ M /) and M = SIZE(ARRAY).
Case (iii): The result of SORT_UP(ARRAY, DIM=k) contains the same elements as A, but each one-dimensional array section of the form ARRAY (i1,i2,...,ik+1,:,ik-1,...,in,, where n is the rank of ARRAY, has been sorted in ascending element order, as in Case(i) above.
Case (i): SORT_UP( (/30, 20, 30, 40, -10/) )
has the value [-10 20 30 30 40].
/ \ | 1 9 2 | If A is the array | 4 5 2 |, | 1 2 4 | \ / / \ | 1 2 4 | then SORT_UP(A) has the value | 1 2 5 |, | 2 4 9 | \ /
/ \ | 1 9 2 | If A is the array | 4 5 2 |, | 1 2 4 | \ / / \ | 1 2 2 | then SORT_UP(A, DIM = 1) has the value | 1 5 2 |. | 4 9 4 | \ /
Next: SUM_PREFIX(ARRAYDIM, MASK, SEGMENT, Up: Specifications of Library Procedures Previous: SORT_UP(ARRAYDIM)