ILNumerics Ultimate VS

ILMathsortT, S, I Method (InArrayT, OutArrayI, Int32, Boolean, KeyMapperT, S)

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Generic bucket sort algorithm in A along arbitrary dimension

[ILNumerics Computing Engine]

Namespace:  ILNumerics
Assembly:  ILNumerics.Computing (in ILNumerics.Computing.dll) Version: 5.5.0.0 (5.5.7503.3146)
Syntax

public static RetArray<T> sort<T, S, I>(
	InArray<T> A,
	OutArray<I> Indices,
	int dim,
	bool descending,
	KeyMapper<T, S> keymapper
)

Parameters

A
Type: ILNumericsInArrayT
Input array: empty, scalar, vector or matrix
Indices
Type: ILNumericsOutArrayI
[Input/Output] The values in Indices will be returned in the same sorted order as the elements in A. This can be used to derive a permutation matrix of the sorted indices.
dim
Type: SystemInt32
Dimension to sort along
descending
Type: SystemBoolean
Specifies the direction of sorting
keymapper
Type: ILNumerics.Core.MiscKeyMapperT, S
Instancce of an object of type ILKeyMapper. This object must be derived from ILKeyMapper{T,SubelementType} and match the generic argument T. It will be used to split single elements into its subelements and map their content into bucket numbers. For all reference types except those of type string you will have to write your own ILKeyMapper class for that purpose.

Type Parameters

T
Element type of values of A
S
Subelement type. For element type of string this would be 'char'
I
Element type of indices

Return Value

Type: RetArrayT
Sorted array of the same size as A
Remarks

The data in A will be sorted using the bucket sort algorithm. Data along the dimension dim will get sorted independently. I.e., for dim = 0, columns are sorted independently.

This overload also returns an array 'Indices' which will hold the indices into the original elements after sorting. Therefore, the unsorted indices must be provided by the user on entry. Indices must not be null.

This generic version is able to sort arbitrary element types. Even user defined reference types can be sorted by specifying a user defined ILKeyMapper class instance. Also the type of Indices may be arbitrarily choosen. In difference to the regular sort function overload, Indices must manually be given to the function on entry. Elements in 'Indices' are sorted in the same order as the elements of A.

By using this overload you may use the same permutation matrix several times to reflect the manipulations done to A due multiple sort processes. The Indices given will directly be used for the sorting disregarding initial order.

[ILNumerics Computing Engine]

See Also

Reference