You can sort lines in the region on the second field with:
C-u 2 M-x sort-field
In most cases this will probably be enough. But what if I would want
to sort from the second field to the end of the line?
You can sort lines in the region on the second field with:
C-u 2 M-x sort-field
In most cases this will probably be enough. But what if I would want
to sort from the second field to the end of the line?
Silly recipe:
- mark at the first char of the first line of the region
- go to last char of the last line of the region
- M-x untabify
- add enough spaces to the first line of the region to make it as long
as the longest line in the region
- go to end of the first line, and mark
- go to the beginning of the second field on the last line
- M-x sort-columns
Replace region with full buffer, if that's what you need
First and last line can be reversed above
Use C-u M-x sort-columns to reverse the sort order, as usual
* Cecil Westerhof <Cecil@decebal.nl>
| You can sort lines in the region on the second field with:
| C-u 2 M-x sort-field
| In most cases this will probably be enough. But what if I would want
| to sort from the second field to the end of the line?
Mark the region and call
C-u M-x shell-command-on-region RET sort -k FIELDNUM RET
-k, --key=KEYDEF
sort via a key; KEYDEF gives location and type
KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position, where
F is a field number and C a character position in the field; both are
origin 1, and the stop position defaults to the line's end. [...]
? Of course requires an external command compatible with Unix' 'sort(1)'.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 02:43:17 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
10 files (20,373K bytes) |
| Messages: | 264,331 |