sorttbl - sort an rdb table
sorttbl [options] [-r] column [[-r] column] ...
Check that the rdbtable is sorted on the selected columns.
Print this help information.
Reverse order. Applies to the following column only.
Make rows unique on selected columns.
sorttbl sorts an rdbtable on one or more columns. Each column may be sorted in normal (ascending) or reverse (descending) order. A column of monthnames (Jan, Apr, ...) in any case letters, may be sorted.
This operator reads an rdbtable via STDIN and writes an rdbtable via STDOUT. Options may be abbreviated. It uses the UNIX sort routine.
For example, to sort a table on the COUNT and TYP columns,
sorttbl COUNT TYP < sample
would produce:
NAME COUNT TYP AMT OTHER RIGHT
6 5N 4 5N 8 8>
Bush 44 A 133 Another This
Hansen 44 A 23 One Is
Holmes 65 D 1111 On Edge
Perry 77 B 244 And The
Hart 77 D 1111 So Right
Jones 77 X 77 Here On
Of course it would look better if it was piped through ptbl.
The command:
sorttbl COUNT -r AMT < sample
would produce:
NAME COUNT TYP AMT OTHER RIGHT
6 5N 4 5N 8 8>
Bush 44 A 133 Another This
Hansen 44 A 23 One Is
Holmes 65 D 1111 On Edge
Hart 77 D 1111 So Right
Perry 77 B 244 And The
Jones 77 X 77 Here On
Walter Hobbs