Description

A CMcDBQuery object can have the McDBNodes matching its specification returned in sorted order using this method. Sort orders are applied in the order added. That is, the first call to AddSortOrder sets a primary sorting key, and subsequent call(s) specify secondary sorting key(s) (i.e. only used as a “tiebreaker” for equal values of the more primary sorting key(s)).

Return Type

None  

Syntax

object.AddSortOrder [SortKey], [Order]

The AddSortOrder Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McDBQuery.
SortKeyOptional. A mcDBSortItem enumeration, as described in settings.

The key to use as the basis for sorting.

OrderOptional. A mcDBOrdering enumeration, as described in settings.

Whether items are sorted on the specified key in ascending or descending order.

Settings

The settings for SortKey are:

ConstantValueDescription
 mcdbName0

Sort by Name

 mcdbCreator1

Sort by Creator

 mcdbCreateDate2

Sort by Date Created

 mcdbModifier3

Sort by Modifier

 mcdbModifyDate4

Sort by Date Modified

 mcdbTypeName5

Sort by Name of McDBType

 mcdbAttributeValue6

Sort by Named Attribute [Value] (not valid for McDBNodes.AddSortOrder)

 mcdbCategory7

Sort by Category

 mcdbDataString8

Sort by Strings in Data Property

The settings for Order are:

ConstantValueDescription
 mcdbAscending0

Sort in Ascending Order

 mcdbDescending1

Sort in Descending Order

 mcdbNone2

Do not Sort

Remarks

As McDBQuery objects are inherently stateful, there are certain rules that prescribe the behavior of this method and when it is usable:

  1. If SortKey is mcdbTypeName, mcdbAttributeValue, mcdbCategory, or mcdbDataString, this method determines the sort order on successive calls to SetType(), SetAttribute(), SetCategory(), and SetDataString(), respectively. Therefore this method may be called after the query specification begins only if one of these three values is used for SortKey. [e.g. To have the results sorted with ascending values for the first attribute primarily, then in descending values for a second attribute, call this method twice during the entire specification: once before each call to SetAttribute()]. To turn off sorting on any of these keys for successive calls to SetType() and/or SetAttribute(), call this method with Order set to mcdbNone.

  2. Calling this method multiple times with different Order values for the same SortKey will have no effect, except for the SortKey values mcdbTypeName, mcdbAttributeValue, mcdbCategory, and mcdbDataString, as described above.