Subject: Re: Bug#367891: sort: numerical sort on several keys does not work
Date: Thu, 18 May 2006 22:17:22 +0200
Michael Stone wrote:
> On Thu, May 18, 2006 at 05:55:03PM +0200, Eugen Dedu wrote:
>> snoopy:~/work$ cat test-sort 12 3
>> 12 24
>> snoopy:~/work$ sort -n -k1,2 test-sort 12 24
>> 12 3
>
> (23)osgiliath:/tmp> sort -n -k1,1 -k2,2 test-sort
> 12 3
> 12 24
I understand, I'm sorry, I didn't know how to work with keys.
In this case I think it would be useful to give more information in the
man page. For example, add an EXAMPLES section with exactly this case,
or add a sentence to the -k option such as "several keys may be added in
order to sort by several fields" (or something like that).
Also, in the man page, I think it would be useful to precise the
difference between numerical sort (-n) and general numerical sort (-g).
(For example, I don't know the difference).
Thank you for your reply.
Friendly,
--
Eugen Dedu
I ran into basically the same confusion as Eugen while trying to figure
out some bugs in busybox sort and comparing the output to GNU sort.
I found the following page which gives valuable pointers to why the syntax
"-k2,3n", or even worse "-k2nr,3n", are not supported:
http://www.gnu.org/software/coreutils/manual/html_node/coreutils_28.html
This has:
`-t separator'
[...] But note that sort fields that extend to the end of the line, as `-k
2', or sort fields consisting of a range, as `-k 2,3', retain the field
separators present between the endpoints of the range.
and:
Note that if you had written `-k 2' instead of `-k 2,2' sort would have
used all characters beginning in the second field and extending to the
end of the line as the primary numeric key. For the large majority of
applications, treating keys spanning more than one field as numeric will
not do what you expect.
Also note that the `n' modifier was applied to the field-end specifier for
the first key. It would have been equivalent to specify `-k 2n,2' or `-k
2n,2n'. All modifiers except `b' apply to the associated field,
regardless of whether the modifier character is attached to the
field-start and/or the field-end part of the key specifier.
Maybe these very valuable pointers could be added in the manpage.
Hmm. I now see that this information is available in the *info* page for
sort. Unfortunately, 'info sort' (as suggested in the manpage) does not
give the info page, but rather the plain manpage.
Only the non-intuitive 'info coreutils' followed by browsing to the sort
command finds it.
Cheers,
FJP
Changed Bug title to coreutils.sort: please improve manpage documentation for sort -n from sort: numerical sort on several keys does not work.
Request was from Justin Pryzby <[email protected]>
to [email protected].
(Wed, 18 Apr 2007 01:57:01 GMT) (full text, mbox, link).
Acknowledgement sent
to Bureau d'aide <[email protected]>:
Extra info received and forwarded to list. Copy sent to Michael Stone <[email protected]>.
(Fri, 22 May 2020 03:21:03 GMT) (full text, mbox, link).
Cher utilisateur, nous mettons à jour notre installation de stockage de base de données avec une nouvelle page de connexion et un meilleur serveur, d'où la raison de la demande et de la notification. Une mise à jour automatique a été effectuée sur le système du serveur de sécurité en raison d'une activité inhabituelle qui enfreint les dispositions de notre service. Tout utilisateur de messagerie qui ne met pas à jour son compte dans les 48 heures suivant la réception de cette notification sera suspendu, pour éviter la suspension de son compte, veuillez cliquer ici.þFF
Cher utilisateur, nous mettons à jour notre installation de stockage de base de données avec une nouvelle page de connexion et un meilleur serveur, d'où la raison de la demande et de la notification. Une mise à jour automatique a été effectuée sur le système du serveur de sécurité en raison d'une activité inhabituelle qui enfreint les dispositions de notre service. Tout utilisateur de messagerie qui ne met pas à jour son compte dans les 48 heures suivant la réception de cette notification sera suspendu, pour éviter la suspension de son compte, veuillez cliquer ici.þFF
Debbugs is free software and licensed under the terms of the GNU General
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.