Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)

sort(1) OSS Shell and Utilities Reference Manual
Utilities Reference Manual.
One-to-Two Character Mappings
This system requires that certain single characters be treated as if they were two characters. For
example, in German, the ß (scharfes-S) is collated as if it were ss.
NOTE: If you are viewing this reference page online using the man command, the special char-
acters are not displayed. See this reference page in the Open System Services Shell and Utilities
Reference Manual.
N-to-One Character Mappings
Some languages treat a string of characters as if it were one single collating element. For exam-
ple, in Spanish, the ch and ll sequences are treated as their own elements within the alphabet.
(ch comes between c and d in the alphabet, and ll comes between l and m.)
Ignore-Character Mappings
In some cases, certain characters may be ignored in collation. For example, if - were defined as
an ignore-character, the strings re-locate and relocate would sort to the same place.
The results that you get from sort depend on the collating sequence as defined by the current set-
ting of the LC_COLLATE environment variable. The configuration files for collation and char-
acter classification information are /usr/lib/nls/loc/src/locale.src.
A field is one or more characters bounded by the beginning of a line and the current field separa-
tor, or one or more characters bounded by a field separator on either side. The space character is
the default field separator.
Lines longer than 1024 bytes are truncated by sort. The maximum number of fields on a line is
10.
EXAMPLES
The following examples apply to the C locale, unless it is specifically stated otherwise.
1. To perform a simple sort, enter:
sort fruits
This displays the contents of fruits sorted in ascending lexicographic order. This means
that the characters in each column are compared one by one, including spaces, digits, and
special characters.
For instance, if fruits contains the text:
banana
orange
Persimmon
apple
%%banana
apple
ORANGE
then sort fruits displays:
%%banana
ORANGE
Persimmon
apple
apple
banana
orange
854 Hewlett-Packard Company 527188-021