Description
Sort columns by the selected numeric key fields, optionally within groups and
in ascending or descending order. Large inputs are sorted in chunks using
temporary files, so the configured temporary directory must be writable and
have enough space. An explicit tmp= filename prefix takes precedence over the
TMPDIR directory; otherwise /tmp is used. Each run creates a private scratch
directory. Chunk size does not bound total memory: sorting keys and indices
are still retained for the whole dataset.
Synopsis
sgsort <stdin key= key.group=0 #key.asc=true tmp= max=40000 >stdout
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
in |
ifile |
stdin
|
input data |
key |
fields |
Unknown | numeric sorting keys; omitted keys use the group, subgroup and index fields when available; explicit keys are required without a valid group key |
key.group |
int |
0
|
zero-based position in the key list to use as the group key |
#key.asc |
bool |
true
|
sort #key in ascending or descending order |
tmp |
str |
Unknown | nonempty temporary filename prefix; overrides the TMPDIR directory; if omitted, use TMPDIR when nonempty, otherwise /tmp; the parent directory must already exist and be writable; each run creates a private directory |
max |
long |
40000
|
maximum number of columns per temporary chunk file |
out |
ofile |
stdout
|
output data |
Input and output
Input
input data
Output
output data