sort -- sort a file or the standard input
- The text file to be sorted. If the standard input is redirected the standard input is sorted.
- column = 0
- If 0, sort entire text lines, else sort based on data/text starting
in the specified column. Columns are delimited by whitespace. Thus,
12 abc 34 56has four columns, "abc" being in the second.
- ignore_whitespace = no
- Ignore leading whitespace. Useful only when column = 0 and the sort is non-numeric.
- numeric_sort = no
- If set, make numerical (rather than ASCII text) comparisons.
- reverse_sort = no
- If set, sort in reverse text/numeric order.
Sort sorts the contents of the given text file, or the standard input, either on a textual (based on the ASCII collating sequence), or on a numeric basis. If a numeric sort is requested, and either field in any comparison is non-numeric, a string (ASCII) comparison will be made instead.
1. Sort the output of the set command into alphabetic (ASCII collating) order.
cl> set | sort
2. Sort the contents of "file", in reverse ASCII order, ignoring the contents of columns 1 through 4.
cl> sort file rev+ col=5
3. Print a long form directory listing with the files sorted by size, largest files first.
cl> dir | sort num+ rev+ col=3
Only one file can be sorted per call, and only one column or all columns can be used for the sort. The current program is inefficient for large numeric sorting tasks because the same numeric field may be decoded into its corresponding binary value many times.