DSORT(1)

NAME
dsort - multiple key data-file sorting filter

SYNOPSIS
dsort [-aceinr] [-l lines] [[type][column-range]] ...

DESCRIPTION
dsort sorts data it reads from the standard input. It sorts lines based on numerical or alphabetical values in whitespace-separated columns. For when two columns have the same value, you can supply further sorting columns to break ties. dsort sorts by looking at columns you choose, and orders lines so that the data or labels in the chosen columns are ordered. You can name the specific column numbers you want, and you can use the M-N notation to specify a sequence, from M to N, of columns. Ranges can be from small to large or from large to small column numbers. If you don't supply columns to sort with, dsort uses column 1, then 2, then 3, and so on, until it finds a difference, or all columns are used.

You can supply the method for comparing column values: a, for alphabetical, i, for integer, n, for most other numbers, including those with decimal points, or e, for sorting all types of numbers, even ones with exponential scientific notation. If you do not supply the type of sort, dsort chooses the one that is best suited for the data, although this makes dsort do some extra work. For alphabetical sorts, you can request a case-insensitive sort with c; that would make hello match Hello and HELLO. You can reverse the sort from the default ascending order to descending order with r. These sorting types can be specified globally for all columns at once with command line options. Global types can be over-ridden by supplying options for specific columns or ranges of columns.

OPTIONS
[a] Sort fields by alphabetic ordering of columns. [c] Use a case-insensitive comparison for alphabetic comparisons. When used as a type modifier for a specific range of columns, this also forces alphabetic sorting. As a command line option, it only modifies the sorting of alphabetic columns. [e] Sort fields by exponential notation ordering of columns. This is the only true numeric sort that works for all numbers: integers, numbers with decimal points, and exponential (scientific) notation numbers. But it is a lot slower than the other sorting options, especially on machines without floating point hardware. [i] Sort fields by integer ordering of columns. [l lines] Set the maximum number of lines to be read. [n] Sort fields by special numeric ordering of columns. Numbers with decimal points are allowed, and compared by a special fast comparison method that is almost as fast as integer sorting. [r] Reverse the order of comparison for sorting options.

EXAMPLES
Suppose the file ex.dat has the contents below. If you did not specify column types, dsort would infer that columns 1 and 2 were to be sorted alphabetically, column 3, as integers, and column 4, numerically.
red    high    1    3.14
blue    low    2    1.62
green    high    6    2.54
green    low    4    2.71
blue    high    3    1
red    low    5    1
blue    high    3    1
blue    low    2    1.62
green    high    6    2.54
green    low    4    2.71
red    high    1    3.14
red    low    5    1
red    high    1    3.14
blue    low    2    1.62
blue    high    3    1
green    low    4    2.71
red    low    5    1
green    high    6    2.54
red    high    1    3.14
green    low    4    2.71
green    high    6    2.54
blue    low    2    1.62
blue    high    3    1
red    low    5    1
red    high    1    3.14
green    low    4    2.71
green    high    6    2.54
blue    low    2    1.62
red    low    5    1
blue    high    3    1
blue    high    3    1
green    high    6    2.54
red    high    1    3.14
blue    low    2    1.62
green    low    4    2.71
red    low    5    1

LIMITS
Use the -L option to determine the program limits.