*SORT, Name
,
SortType
, Val1
,
Val2
Sorts the values of the specified vector.
Name
Name of the vector to be sorted. This vector can contain real or complex values.
SortType
Criteria used to sort the values:
Values are sorted based on their real value (default).
Values are sorted based on their absolute value.
Values are sorted based on the input permutation vector
(Val1
).
Val1
, Val2
Additional input. The meaning of Val1
,
Val2
varies depending on the specified
SortType
. See below for details.
The following Valx
fields are used with
SortType
= VALUE or ABS:
Val1
Name of the vector in which permutation values will be saved (optional). This should be an empty vector of type integer that was created with the *VEC command. The size of this permutation vector must be identical to the size of the vector to be sorted. After the sort, this vector contains the permutation used to sort the values.
Val2
Order of the sort operation:
Increasing order (default).
Decreasing order.
The following Valx
fields are used with
Method
= PERM:
Val1
Name of the permutation vector used to sort the values. This must be a vector of integer values that was created with the *VEC command. The size of this permutation vector must be identical to the size of the vector to be sorted.
This permutation vector is required when using Method
=
PERM.
The examples below demonstrate using *SORT to sort the values of an input vector.
The following input:
*VEC,V,I,ALLOC,5 V(1)=5,-3,2,0,-1 *SORT,V,VALUE *PRINT,V
generates this output:
-3 -1 0 2 5
To reverse the order, this input:
*SORT,V,VALUE,,1 *PRINT,V
generates this output:
5 2 0 -1 -3