Class: Sort

olympe.dc.transformers. Sort

A transformer that sorts instances according to a specified comparator.

Example:

const alphabetical = lst.transform(new olympe.dc.transformers.Sort(
    new olympe.dc.comparators.String(
        new olympe.dc.valuedefs.StringProperty(olympe.dc.CloudObject.nameProp.getTag())
    ));

new Sort(comparator [, ascending])

Creates a Sort transformer.

Parameters:
Name Type Argument Default Description
comparator olympe.dc.Comparator.<T>

The comparator to use for sorting.

ascending boolean <optional>
<nullable>
true

ascending true to sort in ascending order, false for descending.

Implements:
See:

Methods


getComparator()

Gets the inner comparator

Returns:

The comparator.

Type
olympe.dc.Comparator

getInternalPaths()

Implements:
Returns:
Type
Array.<!Array.<!olympe.dc.query.Relation>>

getName()

Gets this Transformer unique name.

Implements:
Returns:

The name.

Type
string

getTransform(manager, stateResolver, callback)

Get the transformer's transform function. This is the method that implementations of Transformer must provide and is where the actual transformation will take place.

Parameters:
Name Type Description
manager olympe.dc.Manager

The DC manager.

stateResolver olympe.dc.ranking.StateResolver

The state resolver.

callback olympe.dc.Manager.TransformationCallback

The callback.

Implements:
Returns:

The transform function.

Type
olympe.dc.Manager.TransformationCallback

getValueType()

Gets the transformed item's value type. A null value means that the transformer will not change the type of the values (e.g. a sort transformer).

Implements:
Returns:

Returns the transformed listDef value new type or null if this transformer does not change it

Type
function

isAscending()

Checks whether the sort order is ascending or descending.

Returns:

true if sort is ascending.

Type
boolean

serialize(parameters)

Serializes the transformer.

Parameters:
Name Type Description
parameters olympe.dc.query.Parameters

The parameters for the serialization.

Implements:
Throws:

If the transformer is not serializable.

Type
Error
Returns:

The JSON representation.

Type
string

toString()

Gets a string representation of the transformer.

Implements:
Returns:

The representation.

Type
string