Key used for sorting action results. The sort
block can contain control flow, like the switch
statement in the below example, in which each terminal node specifies the desired sort order. All action inputs are in scope within the sort block.
action (MyAction) {
type (Search)
collect {
input (mySort) {
type (MySortEnum)
}
}
...
output (MyOutputType) {
...
sort {
switch (mySort) {
case (PriceAsc) {
each (r) {
sorting (r.price) { // this example sorts property `price` that belongs to the model `r`
by (Desc) // It does this in descending order
inverted // Then inverts the sort
}
// compound in case of a tie
ranking (-1 * r.price)
}
}
case (FooBarBaz) {
each (r) {
sorting (r) {
by (SomeOtherCriteriaDefined) // You can pick a different property or criteria that `r` has to sort by.
}
}
}
default {
each (r) {
// use natural order of r
sorting (r)
}
}
}
}
}
}
each optional | Specifies a compound sort by providing one of more sorting expressions, ranking expressions, or both (together known as "ordering expressions"), in decreasing precedence |
Copyright 2024 Samsung All rights reserved