sort-table
Minimal shell wrapper around GNU sort. It first removes blank lines with grep '.', then calls sort -t $'\\t' "$@", so tab is always the field separator.
Quick Start
- Command:
... | sort-table [sort-args] - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/sort-table - Fixed delimiter: tab
When To Use This Tool
- Sorting tab-delimited rows without repeatedly spelling out the tab separator
- Passing normal GNU
sortkey or numeric flags through a thin wrapper - Cleaning out blank lines before sorting tabular text
- Reusing a predictable tab-based sort primitive inside bioinformatics shell pipelines
Common Patterns
# Numeric sort on the second tab-delimited column
printf 'z\t10\n\na\t2\nb\t1\n' | sort-table -k 2,2n
# Lexicographic sort on the first column
cat table.tsv | sort-table -k 1,1
# Reverse numeric sort on a score column
cat table.tsv | sort-table -k 3,3nr
Recommended Workflow
- Make sure the input is truly tab-delimited text.
- Pass ordinary GNU
sortarguments exactly as you would tosort, except you do not need to specify-t $'\\t'. - Write the sorted output to stdout or redirect it to a file.
- If you need documentation for flag semantics, consult GNU
sort, not this wrapper.
Guardrails
- Blank lines are dropped unconditionally because the wrapper begins with
grep '.'. -his not help here; it is forwarded to GNUsortas the human-numeric flag, sosort-table -hwith no data does not print usage.--versionis forwarded to GNUsort; in this environment it reportedsort (GNU coreutils) 9.10.- In live testing,
printf 'z\t10\n\na\t2\nb\t1\n' | sort-table -k 2,2nyieldedb\t1,a\t2,z\t10.