cArray: SortEx

SortEx

Sorts an array, or subportion, given a startindex and length. An optionally supplied comparer object can be used to compare special elements, such as userdefined values.



 Public Sub SortEx(
	  ByRef Keys As Variant,
	  ByVal Index As Long,
	  ByVal Count As Long,
	  Optional ByVal Comparer As Variant )

Parameters

Keys
[ByRef] Variant. The array to sort.
Index
[ByVal] Long. The starting index in the array to start sorting.
Count
[ByVal] Long. The number of elements to be sorted.
Comparer
[ByVal] Optional. Variant. (Optional) An IComparer object or address of a comparer callback function.

Remarks

The Comparer parameter can be an IComparer object or a callback address to a compare function using the AddressOf method. The callback method signature is defined as follows:

 Public Function SortCallback(ByRef x As [Array Datatype], ByRef y As [Array Datatype]) As Long
     ' return a negative value if x is less than y.
     ' return a positive value if x is greater than y.
     ' return 0 if x equals y.
 End Function
 
The [Array Datatype] must be replaced with the datatype of the array. If the array is an array of Variants, then [Array Datatype] would be a Variant, not any specific sub-type within the variants of the array.

See Also

Project VBCorLib Overview Class cArray Overview cArray Properties cArray Methods Sort SortKey