sort Statement
Syntax |
| |
---|---|---|
Semantics |
It is not determined what sort algorithm will actually be used, though a Quicksort derivative is the most common. Be aware that sort algorithms are not linear (typically n log n to n2 iterations for n elements). Therefore, you should keep the expression as compact as possible. When using a boolean expression, make sure that equality always returns true (e.g. by using <= instead of <). Otherwise, the implemented sort algorithm may take longer than necessary or not terminate at all. | |
Substitutables |
| Can be any variable or object attribute having the type Array. |
| This expression must use the currently evaluated array element and its next neighbor and indicates if the current order is OK or not. | |
| ||
Examples | Sort an array of integers in ascending order
NONE
Sort an array of strings in ascending order
NONE
Sort an array using dates in descending
NONE
Sort an array using boolean return values
NONE
Sort an array with complex elements over 2 sort key
NONE
|
Return Values of sort()
an integer | < 0 |
|
= 0 |
| |
> 0 |
| |
a boolean | true |
|
false |
|