Subject: sort: numerical sort on several keys does not work

From: Eugen Dedu <[email-masked]>
Date: Thu, 18 May 2006 17:55:03 +0200

Package: coreutils
Version: 5.94-1
Severity: normal

Hi,

snoopy:~/work$ cat test-sort 
12 3
12 24
snoopy:~/work$ sort -n -k1,2 test-sort 
12 24
12 3
snoopy:~/work$ echo $LC_ALL
C
snoopy:~/work$ 

Is 24 smaller than 3?!

Friendly,
Eugen Dedu

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable')
Architecture: powerpc (ppc)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-powerpc
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages coreutils depends on:
ii  libacl1                       2.2.37-1   Access control list shared library
ii  libc6                         2.3.6-7    GNU C Library: Shared libraries
ii  libselinux1                   1.30-1     SELinux shared libraries

coreutils recommends no packages.

-- no debconf information

---

From: Michael Stone <[email-masked]>
Date: Thu, 18 May 2006 13:22:26 -0400

>snoopy:~/work$ sort -n -k1,2 test-sort 

(23)osgiliath:/tmp> sort -n -k1,1 -k2,2 test-sort
12 3
12 24

---

From: Eugen Dedu <[email-masked]>
Date: Thu, 18 May 2006 22:17:22 +0200

Michael Stone wrote:
>> snoopy:~/work$ cat test-sort 12 3
>> 12 24
>> snoopy:~/work$ sort -n -k1,2 test-sort 12 24
>> 12 3
> 

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