Sorted by
- Last Updated: November 6, 2023
- 2 minute read
- Corticon
- Version 6.3
- Documentation
SYNTAX
<Collection>
->sortedBy(<Attribute2>) -> sequence operator.<Attribute1>
Sequences the elements of <Collection> in ascending order, using
the value of <Attribute2> as the index, and
returns the <Attribute1> value of the element
in the sequence position determined by the sequence operator. A sequence must be
created before any sequence operator ( ->first,
->last, or ->at) is used to identify a particular
element. <Attribute1> and <Attribute2> must be attributes of <Collection>.
<Attribute2> may be any data type except Boolean.
Strings are sorted according to character precedence – see Character precedence in Unicode and Java Collator. <Collection> must be expressed as a unique
alias.
The Operators row of the table in Summary Table of Vocabulary Usage Restriction applies. No special exceptions.
This sample Rulesheet uses ->sortedBy in a conditional expression to create an ascending sequence
from collection with decimal1 as the index.
->first.string1 is used to return the value of the string1 attribute of the first element of the
sequence. If the value of string1 is Joe, then boolean1
attribute of Entity1 is assigned the value of
true.
A sample Ruletest provides a collection of
three elements, each with a decimal1 and string1 value. Input and Output panels are shown
below.
This sample Rulesheet uses ->sortedBy in
an action expression to create an ascending sequence from collection with decimal1 as the
index. ->first.string1 is used to return the
value of the string1 attribute of the first element
of the sequence. The value of string1 is assigned
the value of Joe if boolean1 attribute of Entity1 is
true, if false
it is assigned the value of Mary.
A sample Ruletest provides a collection of three elements, each with
a decimal1 and string1 value. Input and Output panels are shown below.