Sort
Last updated
Was this helpful?
Last updated
Was this helpful?
Select a range of cells > go to the Home tab > Editing > Sort & Filter and then select sorting options.
Rank can be added as a table calculation or with the syntax:
~RANK!~(‹field› «, 'direction'») where «direction» can be either asc
or desc
.
Use the Sort tool (in the Preparation palette).
(and select the Sort and Direction values).
In OrgVue, strings and numbers are sorted differently. Sorting strings: array(‹string_array›).~sort!~('item'«, 'direction'») OR ‹collection›.~sort!~('‹dimension›'«, 'direction'»)
NB.:
If no direction is supplied, an ascending order is applied by default.
If the values being sorted are of mixed type, sort()
lists numbers in ascending order and then sorts strings alphabetically (which can be considered 'ascending order').
Sorting numbers:
It is possible to apply the above syntax when sorting a measure. However, it will treat the measure as if it were a string, e.g. sorting 9.9 -> 800 -> 70 -> ... To correctly sort numerical fields, use: ‹collection›.~sort!~('‹measure›', ~sort.number!~|sort.‹direction›)
~ORDER BY!~ ‹field› [‹direction›]
~sorted!~(‹arr›, ‹key=lambda n: n.name›)
This assumes that the variable arr
is an array containing objects. If you want to sort a simple array of strings, you can use:
~sorted!~(‹array›, «reverse=True»)
where the inclusion of reverse=True
reverses the sort order:
NB.:
An ascending order is applied by default.
If the values being sorted are of mixed type, sorted()
lists numbers in ascending order and then sorts strings alphabetically (which can be considered 'ascending order').
All numbers must be wrapped in quotes.