# OrderedIndexType reference

The OrderedIndexType is defined in

    type/OrderedIndexType.h

. It allows to specify its only argument, the selection of the key fields, in the constructor, or set it later with a chainable call:

    OrderedIndexType(NameSet *key = NULL);
    static OrderedIndexType *make(NameSet *key = NULL);
    OrderedIndexType *setKey(NameSet *key);

The ascending or descending order of sorting by a particular field is encoded in the field name. If the name is prepended with a !, the order is descending, otherwise ascending.

As usual, the NULL values in the key fields are permitted, and are considered less than any non-NULL value. The array fields may also be used as keys in the ordered indexes. The comparison of the strings honors the order defined in the locale.

The key can be read back using the parent class methods

    IndexType::getKey()

and

    IndexType::getKeyExpr()

. The value returned there is a

    const NameSet*

, telling you that the key NameSet must not be changed afterward.

    getKeyExpr()

returns the key as it was specified during construction,

    getKey()

strips any ! prefixes and returns purely the names of the fields.
OrderedIndexType