Subject: Re: bug#9334: sort bug

From: Eric Blake <[email-masked]>
Date: Mon, 22 Aug 2011 08:44:57 -0600

On 08/22/2011 07:47 AM, ROGER GRAYDON CHRISTMAN wrote:
> Thanks.  I guess I misinterpreted "uses a default key of the entire line"
> as "uses the entire line as keys by default", in which case if the first column
> was equal, it would compare the second, then the third, etc.
>
> I guess I don't know what "default key of the entire line" means with respect
> to -n,
> since it apparently didn't treat "1    12" as "112" and "1   4" as 14.
> I'm curious to find out what this phrase means in this context.

'sort --debug' is your friend.  In the C locale, global -n means 'parse 
as much of the prefix of the line as can be treated as a number as the 
primary key, then treat the entire line as the secondary key'.

$ printf ' 1 12\n 1  4\n 5 16\n 9 20\n' | LC_ALL=C sort --debug -n
sort: using simple byte comparison
  1  4
  _
_____
  1 12
  _
_____
  5 16
  _
_____
  9 20
  _
_____

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org