asort(1)asort(1)NAMEasort - Sorts or merges files and supports multiple collating weight
SYNOPSISasort [-m] [-o output_file] [-Abdfinruv] [-Ccollate_sequence] [-k key‐
def]... [-t character] [-T directory] [-y] [kilobytes] [-z
asort-c [-u] [-Abdfinruv] [-Ccollate_sequence] [-k keydef]... [-t
character] [-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] [-Ccol‐
late_sequence] [-o output_file] [-t character] [-T directory] [-y]
[kilobytes] [-z record_size] [+fskip] [.cskip] [-fskip] [.cskip]
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 charac‐
ters, including user-defined characters (UDCs).
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 speci‐
fies the long and short collation weight names that are valid
for supported codesets.
For DEC Hanzi:
Pinyon (or p) Radical (or r) Stroke (or s) For DEC Hanyu, Tai‐
wanese EUC, and BIG-5:
Phonetic (or p) Radical (or r) Stroke (or s) Uses a breadth-
first sorting mechanism instead of the default depth-first mech‐
anism 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 in common.
The asort command provides additional features for processing multiple
collating weight sequences used with Asian languages, such as Chinese.
For example, pinyon (p), stroke (s), and radical (r) are three dimen‐
sions along which characters can be ordered in Simplified Chinese. The
-C option allows users to specify the priority level that these dimen‐
sions have during sorting. For example, -C srp specifies that charac‐
ters 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 characters.
When the -C option is specified, the default behavior of the asort com‐
mand 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
However, the asort command provides the -v option to use the Asian VMS-
like breadth-first sorting mechanism. With the breadth-first mecha‐
nism, pairs of multibyte characters in a sort field are compared using
the first collating 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 sorting.
Currently, the asort command is supported for use only with Chinese
The asort command returns the following exit values: All input files
were output successfully, or -c was specified and the input file was
correctly sorted. 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 equal keys. An error occurred.
Unless stated otherwise, the following examples assume the locale set‐
ting is zh_TW.dechanyu: To perform character sorting first by stroke
and then by radical, enter: 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 fol‐
lows: asort-Csr names To perform string sorting first by stroke
and then by radical in a way similar to the sort command avail‐
able on an Asian VMS system, enter: asort-v -C"Stroke Radical"
Others: Chinese(5), i18n_intro(5)asort(1)