Click or drag to resize

IMcOMGlobalMcSort Method

Sorts an array of numbers or a "list" of strings and returns a selector which will select the elements in sorted order.

Namespace:  MediaCy.IQL.ObjectManager
Assembly:  MediaCy.IQL.ObjectManager (in MediaCy.IQL.ObjectManager.dll) Version: 10.0.6912.0
Syntax
VB
Function McSort ( 
	varValsOrListToSort As Object,
	Optional bAscending As Boolean = true
) As McObject

Parameters

varValsOrListToSort
Type: SystemObject
Array of values or strings to sort.
bAscending (Optional)
Type: SystemBoolean
If True (the default), the sort is ascending. If False, the sort is descending.

Return Value

Type: McObject
A McObject instance holding a selector identifying the sorted order of varValsOrListToSort. The returned result will be of type mcobjTypeINTEGER. And it will be the same shape as varValsOrListToSort.
Remarks
This method returns a "selector" giving the sorted order; it does not return the sorted array itself. To get the sorted array, use the McObject.SelectedValues method (see Example). For Single and Double source arrays, missing values (see McMissingSingleValue, McMissingDoubleValue and McIsMissingValue) are considered to be as small a number as possible, so they will all be clustered at the front of the sorted order for ascending sorts and at the end for descending sorts. In both descending or ascending sorts, the original relative ordering is maintained for sorted elements with identical values. The sorting algorithm used is a Quicksort. The sorting time is proportional to some N*log(N) on the average, but may be proportional to N*N in the worst case.
Examples
VB
'Sort some random values
Dim mcoRandom As McObject
Set mcoRandom = McRand(10)  'get 10 random values
Dim selSorted As McObject
Set selSorted = McSort(mcoRandom)  'get selector to sorted order
Dim mcoSortedValues As McObject
Set mcoSortedValues = mcoRandom.SelectedMcObject(selSorted)
Debug.Print "Random Values: " & McToText(mcoRandom) & vbCrLf & _
"Sorted selector: " & McToText(selSorted) & vbCrLf & _
"Sorted Values: " & McToText(mcoSortedValues)
See Also