sort
Sort text lines from files or stdin with options for numeric, reverse, and unique ordering. Returns sorted lines for downstream processing.
Instructions
Sort text lines deterministically from files or stdin. Read-only, no side effects. Use --numeric for numerical sort, --reverse for descending order, --unique to remove duplicates, and --seed for deterministic tie-breaking. Returns JSON with sorted lines by default; use --raw for plain output. Use to order data for downstream processing. Not for deduplication of non-sorted data — pipe to 'uniq' for adjacent dedup. Not for randomizing — use 'shuf'. See also 'uniq', 'shuf'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| raw | No | Write plain transformed text to stdout. | |
| check | No | Check whether input is sorted; exit non-zero if not. | |
| paths | No | Files to sort, or '-' for stdin. Defaults to stdin. | |
| stable | No | Stable sort: preserve relative order of equal keys. | |
| unique | No | Emit only the first of equal sorted lines. | |
| numeric | No | Sort by the first numeric token. | |
| reverse | No | Reverse the sort order. | |
| encoding | No | Text encoding (default: utf-8). Use 'auto' for BOM/autodetection. | utf-8 |
| max_lines | No | Maximum JSON lines to emit. | |
| ignore_case | No | Compare case-insensitively. | |
| show_encoding | No | Include encoding detection metadata in JSON result. | |
| encoding_errors | No | How to handle encoding errors (default: replace). | replace |
| encoding_profile | No | Locale-aware encoding fallback profile for auto-detection. |