Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.emacs.help > #60699
| Path | csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | gnu.emacs.help |
| Subject | Re: Sort from second field instead on second field |
| Date | Thu, 30 Mar 2023 07:03:03 +0200 |
| Organization | Decebal Computing |
| Lines | 58 |
| Message-ID | <87355mltko.fsf@munus.decebal.nl> (permalink) |
| References | <87sfdnlfkj.fsf@munus.decebal.nl> <yga4jq3v55a.fsf@akutech.de> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | dont-email.me; posting-host="f63cbbb829732f3d519cd3ed277b2435"; logging-data="755633"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gleA1Psa4vsdtXOX2g8qzJtz4GaMeZWo=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
| Cancel-Lock | sha1:v3MSXRqE6z9eWLWTUmiUxJ3rSgg= sha1:7uzbguA5LSfvmIQqgP3uSrlx1/k= |
| Xref | csiph.com gnu.emacs.help:60699 |
Show key headers only | View raw
Ralf Fassel <ralfixx@gmx.de> writes:
> * 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)'.
For me that would work because I am on Debian. I was thinking about
this originally, but then I saw that Emacs had his own internal
commands. So I thought that is better. It can be done in the way HASM
said. (And it is really neat.) But I think that this is a better, or
at least easier way. So next time I will use the external sort
command.
Thanks.
I have:
📱 Mobile Phone
😭 Loudly Crying Face
🪟 Window
🏡 House with Garden
💔 Broken Heart
🏠 House
🥳 Partying Face
🥵 Hot Face
And when using (I prefer long options):
C-u M-x shell-command-on-region RET sort --key=2 RET
I get:
💔 Broken Heart
🥵 Hot Face
🏠 House
🏡 House with Garden
😭 Loudly Crying Face
📱 Mobile Phone
🥳 Partying Face
🪟 Window
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to gnu.emacs.help | Previous | Next — Previous in thread | Find similar
Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-29 17:53 +0200
Re: Sort from second field instead on second field HASM <hasm@example.invalid> - 2023-03-29 09:39 -0700
Re: Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-29 19:55 +0200
Re: Sort from second field instead on second field Ralf Fassel <ralfixx@gmx.de> - 2023-03-29 19:28 +0200
Re: Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-30 07:03 +0200
csiph-web