#SORT Built-In Function
Use #SORT to sort a space-separated list of text.
option
specifies the order in which the indicated text is to be sorted. If you omit option,
ascending order is the default. If, however, there is any chance that the text may
begin with a slash (/), you must include an option so that the slash in the text is not
interpreted as the beginning of the option. option is one of the following:
ASCENDING
specifies that the text is to be sorted in ascending order according to the ASCII
collating sequence.
DESCENDING
specifies that the text is to be sorted in descending order according to the
ASCII collating sequence.
text
specifies a space-separated list to be sorted. If not specified, #SORT does nothing.
Result
#SORT returns a sorted space-separated list.
Considerations
• #SORT upshifts all characters before comparing them, so uppercase and
lowercase forms of the same character sort as equal; equal characters do not
change position with regard to each other during sorting.
• When dealing with characters from the upper half of the international character set,
the character-processing rules in effect have an influence on #SORT (see the
following examples).
Examples
1. The following example illustrates the use of #SORT on a specified list of
characters:
65> [#DEF pogo TEXT |BODY| albert howland churchy
grundoon]
66> #OUTPUT [#SORT /DESCENDING/ [pogo]]
albert churchy grundon howland
#SORT [ / option / ] [ text ]
2. The following example illustrates the way in which equal-valued uppercase and
lowercase characters are sorted.
67> #OUTPUT [#SORT /ASCENDING/ a B b A]
a A B b
3. The following examples show the influence of character-processing rules. The first
instance shows the result when the CPRULES0 rules, which cause a number of
international characters to lose their diacritical marks when upshifted, are in effect:
68> #OUTPUT [#SORT /ASCENDING/ B a a A b]
a â A B b
The second instance shows the result when CPRULES1 rules, under which
diacritical marks remain intact during upshifting, are in effect:
69> #OUTPUT [#SORT /ASCENDING/ B a â A b]
a A B b â
Partager