asort - Sorts or merges files and supports multiple collating weight
asort [-m] [-o output_file] [-Abdfinruv] [-Ccollate_sequence] [-k key-
def]... [-t character] [-T directory] [-y] [kilobytes] [-z record_size]...
asort -c [-u] [-Abdfinruv] [-Ccollate_sequence] [-k keydef]... [-t charac-
ter] [-T directory] [-y] [kilobytes] [-z record_size]... file...
The following syntax is maintained for backward compatibility but may be
withdrawn in a future release:
asort [-Abcdfimnruv] [-Ccollate_sequence] [-o output_file] [-t character]
[-T directory] [-y] [kilobytes] [-z record_size] [+fskip] [.cskip] [-fskip]
[.cskip] [-bdfinr]... file...
The asort command includes the same options as the sort command (see
sort(1)) in addition to the following options:
Specifies the collating weight sequence to be used in sorting the data
files. When this option is specified, the asort command does not use
the collating table from the locale database. Instead, the command
uses a set of special system and user collating tables to determine the
collating weights of characters, including user-defined characters
The collate_sequence argument can be in long form (for example, "Pinyin
Radical Stroke") or short form (for example, prs). The codeset of the
locale determines which collation weight names can be specified for
collate_sequence. The following list specifies the long and short col-
lation weight names that are valid for supported codesets.
+ For DEC Hanzi:
Pinyon (or p) Radical (or r) Stroke (or s)
+ For DEC Hanyu, Taiwanese EUC, and BIG-5:
Phonetic (or p) Radical (or r) Stroke (or s)
-v Uses a breadth-first sorting mechanism instead of the default depth-
first mechanism to sort the input data. To have any effect, the -v
option must be used together with the -C option.
The asort command sorts lines in its input files and writes the result to
standard output. The asort command is similar to the sort command. See the
sort(1) reference page for information about features the two commands have
The asort command provides additional features for processing multiple col-
lating weight sequences used with Asian languages, such as Chinese. For
example, pinyon (p), stroke (s), and radical (r) are three dimensions along
which characters can be ordered in Simplified Chinese. The -C option
allows users to specify the priority level that these dimensions have dur-
ing sorting. For example, -C srp specifies that characters should be sorted
first by stroke, then by radical, then by pinyon. The specified sequence is
applied to user-defined characters (UDCs) as well as to standard charac-
When the -C option is specified, the default behavior of the asort command
is to use a depth-first sorting mechanism to sort the input files. With
the depth-first mechanism, pairs of multibyte characters in a sort field
are compared by exhausting all the specified collating weights and/or
internal codes one at a time until the collating order is resolved. Only
when two characters are identical is the next pair of characters compared.
The depth-first sorting mechanism is also called character sorting.
However, the asort command provides the -v option to use the Asian VMS-like
breadth-first sorting mechanism. With the breadth-first mechanism, pairs
of multibyte characters in a sort field are compared using the first col-
lating weight for all the characters in the sort field first. Only when
two sets of data in a sort field are computed to have the same collating
order are succeeding collating weights used for resolving the collating
order. The breadth-first sorting mechanism is sometimes called string
Currently, the asort command is supported for use only with Chinese
The asort command returns the following exit values:
0 All input files were output successfully, or -c was specified and the
input file was correctly sorted.
1 If -c was specified, the file was not ordered as specified, or if the
-c and -u options were both specified, two input lines were found with
>>1 An error occurred.
Unless stated otherwise, the following examples assume the locale setting
1. To perform character sorting first by stroke and then by radical,
asort -C"Stroke Radical" names
This command displays the lines in names sorted in ascending order
according to the number of strokes in characters. If the number of
strokes happen to be the same for two characters, the radicals of the
characters determine how the characters are ordered.An alternative
short form of the same command is as follows:
asort -Csr names
2. To perform string sorting first by stroke and then by radical in a way
similar to the sort command available on an Asian VMS system, enter:
asort -v -C"Stroke Radical" names
Others: Chinese(5), i18n_intro(5)