An LLM wrote this README so beware.
A utility script for sorting top-level headings in Org-mode files. It reads an Org file from standard input, sorts its top-level headings based on specified keys, and writes the sorted output to standard output. Requires `emacs` with `org-mode`.
Basic usage:
./org-sort.el -- --key=a < input.org > output.orgNote double dash before actual options.
Multiple keys can be specified. The first key given acts as the primary sort key.
./org-sort.el -- --key=t --key=a < input.org > output.orgCombined codes can also be used with `-k`:
./org-sort.el -- -k pA < input.org > output.orgBut emacs option parsing apparently does not like -- -kpA. You need the space in there.
Uppercase reverses the sort order.
| Code | Description |
|---|---|
| `a` | Alphabetical (headline text) |
| `n` | Numeric within headline |
| `o` | TODO keyword order |
| `p` | Priority cookie |
| `s` | SCHEDULED timestamp |
| `d` | DEADLINE timestamp |
| `t` | Other timestamp in headline |
- Sort alphabetically:
./org-sort.el -- --key=a < in.org - Sort by SCHEDULED timestamp (descending), then by priority (ascending):
./org-sort.el -- -k S -k p < in.org - Sort by TODO keyword order (ascending):
./org-sort.el -- --key=o < in.org