Description

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

Return Type

A McObject object.  

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.

Syntax

object.McSort (varValsOrListToSort, [bAscending])

The McSort Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McOMGlobal.
varValsOrListToSortRequired. A Variant value.

Array of values or strings to sort.

bAscendingOptional. A Boolean value.

If True (the default), the sort is ascending. If False, the sort is descending.

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.