Your message dated Sun, 8 Jan 2012 23:08:05 -0700
with message-id <[email protected]>
and subject line Re: Bug#655186: /usr/bin/sort: sorting by fields not working
has caused the Debian Bug report #655186,
regarding /usr/bin/sort: sorting by fields not working
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
655186: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=655186
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: coreutils
Version: 8.13-3
Severity: normal
File: /usr/bin/sort

Hello,

I may be doing something wrong here, but it seems to me that sort is
ignoring my secondary sort key:

$ cat sample
unknown_26:471000000:3
WXTV:225000000:541
WWOR_HD:465000000:1
WWOR:225000000:509
WTBS:429000000:450
WPIX:225000000:511
WNYW:225000000:505
WNJU:225000000:547
WNET_HD:453000000:2
WNET:225000000:513
WNBC_HD:471000000:1
WNBC:225000000:504
WFUT:225000000:568
WCBS_HD:453000000:1
WCBS:225000000:502
WABC_HD:471000000:2
WABCDT3:471000000:16
WABC:225000000:507
VME:453000000:4
TVGN:435000000:470
RTTV:135000000:303
PBSKIDS:453000000:3
NY1:435000000:468
CSPAN3:351000000:115
BONTV:219000000:84
$ sort -ns -t: -k2,3 < sample
RTTV:135000000:303
BONTV:219000000:84
WXTV:225000000:541
WWOR:225000000:509
WPIX:225000000:511
WNYW:225000000:505
WNJU:225000000:547
WNET:225000000:513
WNBC:225000000:504
WFUT:225000000:568
WCBS:225000000:502
WABC:225000000:507
CSPAN3:351000000:115
WTBS:429000000:450
TVGN:435000000:470
NY1:435000000:468
WNET_HD:453000000:2
WCBS_HD:453000000:1
VME:453000000:4
PBSKIDS:453000000:3
WWOR_HD:465000000:1
unknown_26:471000000:3
WNBC_HD:471000000:1
WABC_HD:471000000:2
WABCDT3:471000000:16
$ 

As you can see, it sorts correctly by the second field, but the lines are
still out of order with respect to the third field.

Please let me know if I'm doing something wrong here.
--Joe

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.1.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages coreutils depends on:
ii  dpkg          1.16.1.2
ii  install-info  4.13a.dfsg.1-8
ii  libacl1       2.2.51-5
ii  libattr1      1:2.4.46-5
ii  libc6         2.13-24
ii  libselinux1   2.1.0-4

coreutils recommends no packages.

coreutils suggests no packages.

-- no debconf information



--- End Message ---
--- Begin Message ---
Joseph Nahmias wrote:
> I may be doing something wrong here, but it seems to me that sort is
> ignoring my secondary sort key:

Well...  You called it! :-) You are doing something wrong here.  I
closed the bug.  If you disagree then feel free to open it again.
Also please feel free to reply and log more information to the bug
regardless.

> BONTV:219000000:84
> $ sort -ns -t: -k2,3 < sample

Try that same command but this time add the --debug option.

  sort: using simple byte comparison
  sort: key 1 is numeric and spans multiple fields

You are trying to call fields 2,3 as one number.  But it can't be a
number.  Therefore it is only really sorting on the first field.  I
personally like to tag the numeric option to each individual field as
a habit so that different fields can be sorted differently.

Try this instead:

  sort -s -t: -k2,2n -k3,3n < sample

Bob


--- End Message ---

Reply via email to