Sorted by descending
- Last Updated: December 12, 2022
- 2 minute read
- Corticon
- Documentation
SYNTAX
<Collection>
->sortedByDesc(<Attribute2>) -> sequence operator.<Attribute1>
Sequences the elements of <Collection> in descending 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 their ISO character
precedence. <Collection> must be expressed as a unique alias.
See Advanced collection sorting syntax in the Rule Modeling Guide for more examples of usage.
The Operators row of the table in Summary Table of Vocabulary Usage Restriction applies. No special exceptions.
This sample Rulesheet uses ->
sortedByDesc in a conditional expression to create an descending 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 value. Input and Output panels are shown below.
![]()
This sample Rulesheet uses sortedByDesc in an
action expression to create an descending 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 value. Input and Output panels are shown
below.
![]()