next up previous contents
Next: SORT_UP(ARRAYDIM) Up: Specifications of Library Procedures Previous: SORT_DOWN(ARRAYDIM)

SORT_DOWN(ARRAY,DIM)

Optional Argument . DIM

Description . Sort by descending value.

Class . Transformational function.

Arguments .

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.

Result Value .
*

Case (i): The result of SORT_DOWN(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 descending 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_DOWN(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 descending order, as in Case(i), and finally restoring the result to the original shape. That is, it gives the same result as RESHAPE( SORT_DOWN(V), SHAPE = SHAPE(ARRAY) ), where V = RESHAPE( ARRAY, SHAPE = (/ M /) and M = SIZE(ARRAY).

Case (iii): The result of SORT_DOWN(ARRAY, DIM=k) contains the same elements as A, but each one-dimensional array section of the form ARRAY(i1i2,...,ik-1,:,ik+1,...in), where is the rank of ARRAY, has been sorted in descending element order, as in Case(i) above.


Examples .

Case (i): SORT_DOWN( (/30, 20, 30, 40, -10/) ) has the value [40 30 30 20 -10]. Case (ii):

                  /       \
                  | 1 9 2 |
If A is the array | 4 5 2 |
                  | 1 2 4 |
                  \       /

                                /       \
                                | 9 4 2 |
then SORT_DOWN(A) has the value | 5 2 1 |
                                | 4 2 1 |
                                \       /
Case (iii):
                  /       \
                  | 1 9 2 |
If A is the array | 4 5 2 |
                  | 1 2 4 |
                  \       /

                                         /       \
                                         | 4 9 4 |
then SORT_DOWN(A, DIM = 1) has the value | 1 5 2 |
                                         | 1 2 2 |
                                         \       /


next up previous contents
Next: SORT_UP(ARRAYDIM) Up: Specifications of Library Procedures Previous: SORT_DOWN(ARRAYDIM)