Difference between revisions of "SortIndex"
m (adding doc status category) |
|||
Line 1: | Line 1: | ||
[[Category:Functions that create lists]] | [[Category:Functions that create lists]] | ||
− | + | [[Category:Doc Status C]] <!-- For Lumina use, do not change --> | |
+ | |||
Returns a permutation of the index elements re-arranged to indicate the ascending sorted ordering of array elements. | Returns a permutation of the index elements re-arranged to indicate the ascending sorted ordering of array elements. | ||
Revision as of 04:36, 25 April 2007
Returns a permutation of the index elements re-arranged to indicate the ascending sorted ordering of array elements.
Declaration
SortIndex(D : vector[I] ; I : optional Index )
Description
If I is not specified, you should guarantee that D will always be a one-dimensional array. In this case, sortIndex returns an unindexed list of elements.
If I is specified, D may be multi-dimensional. Each slice of D is sorted separately along I, with the result being an array having the same dimensionality of D, but where each element is the corresponding element in I indicating the sort.
Examples
To sort the elemets of an index (in ascending order):
SortIndex( I )
To sort the elements of an array, A, along I:
A[I=sortIndex(A,I)]
To sort an array A (indexed by indexes Row and Col) according to the values in Col='key', use:
A[Row=SortIndex( A[Col='key'],Row)]
Comments
Enable comment auto-refresher