Sort_str
string-functions sort_str(ing)
syntax
- sort_str(string_dataitem)
definition
sort_str(string_dataitem) sorts data-item string_dataitem in ascending order (ASCII sort sequence).
description
The sort_str function is case sensitive.
Use the reverse function on a sorted string to sort in descending order (see example).
applies to
- data item string_dataitem with string value-type
performance
O(n * k * log n) where n = number of strings and k = average string length. String comparisons involve character-by-character comparison.
example
1. attribute<string> sortA_asc (ADomain) := sort_str(A);
2. attribute<string> sortA_desc (ADomain) := reverse(sortA_asc);
| A | sortA_asc | srtA_desc |
|---|---|---|
| ‘Test’ | ’ test met spatie’ | ‘twee woorden’ |
| ‘88hallo99’ | ’+)’ | ‘Test’ |
| ’+)’ | ‘88hallo99’ | ‘88hallo99’ |
| ‘twee woorden’ | ‘Test’ | ’+)’ |
| ’ test met spatie’ | ‘twee woorden’ | ’ test met spatie’ |
ADomain, nr of rows = 5