SortIndex

Revision as of 21:54, 31 January 2007 by Lchrisman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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


You are not allowed to post comments.