KCML_Sort_Record

Purpose

Sort an array of records by given key

Definition

DEFSUB 'KCML_Sort_Record(BYREF Array$(), BYREF Key$()_KCML_SORT_REC_KEY), BYREF Locator(), SortLocator = 0) AS Void

Parameters

ArrayArray of records to be sorted
KeyKey - an array of key segments
LocatorLocator array containing sorted indices, redimmed to number of elements in the record array
SortLocatorOptional. By default sort entire array. If SortLocator is TRUE then only sort elements specified by the LocatorArray

Description

This function sorts an array of records using the given key, returning an array of indices into the record array in sort order. The key array contains zero or more key segments. Each segment specifies the start and pack format to be used and whether the key should be an ascending or descending key. All numeric pack formats sort in Numeric order. The record array is not modified, but instead the Locator() array is redimmed to the number of elements and its values are the indicies into the record array, in sort order. This is much more efficient for large records. If the key contains no segments then the locator array will be in the original order.

See also

Internal KCML Functions, Internally defined structures and Internally defined enumerations and constants.