Skip to content

sort

Sort records from input or from files.

Synopsis

bash
recs sort [options] [files...]

Description

Sort records from input or from files. You may sort on a list of keys, each key sorted lexically (alpha order) or numerically. The sort type may be prefixed with '-' to indicate decreasing order. The sort type may be postfixed with '*' to sort the special value 'ALL' to the end (useful with collate --cube).

Options

FlagDescription
--key / -k <keyspec>Sort key specification. May be comma-separated, may be specified multiple times. Each keyspec is a name or name=sortType. Sort type may be lexical, numeric, nat, lex, n, or l. May be prefixed with '-' for decreasing order. May be postfixed with '*' to sort the special value 'ALL' to the end.
--reverse / -rReverse the sort order.

Examples

Sort on the id field numerically

bash
recs sort --key id=numeric

Sort on age numerically, then name lexically

bash
recs sort --key age=numeric,name

Sort on decreasing size, then name

bash
recs sort --key size=-numeric --key name

Sort numerically, with 'ALL' values last

bash
recs sort --key count=numeric*

See Also

Released under the MIT License.