General:. Glee
has provisions for sorting each of its objects. The rules are object specific.
This section works across many Glee objects and discusses their
behavior to sorting and grading operators.
GLEE Character sort (
>>>): The Glee collating sequence attempts
to deliver the most generally desired sorting result in the most direct fashion
possible. The Glee collating sequence treats all variations of
like characters as if they were the same character. For example, it treats
"AaÀÁÂÃÄÅàáâãäå"
all as just "A". Glee also treats most
non-alphanumeric characters as simple white space. Further, it removes all
"extraneous" whitespace when comparing. Finally, it ignores the
"-" and " ` " characters so
words with or without these characters compare equally. By default, sorts are
Glee sorts. One may explicitly specify the Glee
sort with the operator combination @= >>>
Exact Character sort (@==
>>>) : The Exact collating sequence assigns a collating order
to each character in the ascii sequence. However, the sequence differs from the
ascii sequence and delivers a more usable result than a sort based strictly on
the ascii character order. For example, the "A"'s are
grouped to sort as
"aAàÀáÁâÂãÃäÄåÅ".
One can obtain a pure ascii sort by overriding the Exact collating sequence
with 0..255 =>#CSEXACT.
ASCII Character sort:
(0..255 => #CSEXACT; @== >>>). To obtain a customary
(the way virtually all other languages do it) ASCII sort, you can override the
collating sequence for the Exact character sort. To return to the default exact
sorting sequence use '' => #CSEXACT.
Numeric grade; indexing; and
sorting: Sorting is indexing by a grade vector. Glee produces
a grade up vector with (``> ... read as indices of up)and a
grade down with (``<... indices of down). This result when
used as an index into the original object results in a sort. Glee
also supports sorting directly with ( >>> ... depicts
up) and ( <<< ... depicts down) operators.
Grading and sorting a string:
This illustrates using the grade operator (``>) to obtain indices
for sorting. Also notice when an exact sort (@==) is done, the
collating sequence is different. This is because Glee sorts treat
upper and lower case characters the same. Since Glee is a stable
sort, like elements retain their relative postions. Sorting can be done
directly using the sort operator (>>>)
Sorting sequence of strings:.
Strings are sorted as if they were words. The longer words sort higher than
shorter words. Of course you can use grade and indexing as well.
Hetrogeneous sorting:
Glee will sort anything with anything else. In the case of
hetrogeneous sequences, dissimilar types are ordered according to their
?typen property value.