GNU bug report logs - #11516
sort order

Previous Next

Package: coreutils;

Reported by: e.sambasivarao <e.sambasivarao <at> licindia.com>

Date: Sat, 19 May 2012 06:27:01 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 11516-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: "e.sambasivarao" <e.sambasivarao <at> licindia.com>
Cc: 11516-done <at> debbugs.gnu.org
Subject: Re: bug#11516: sort order
Date: Sat, 19 May 2012 11:31:22 +0100
On 05/19/2012 05:40 AM, e.sambasivarao wrote:
> Dear Sir,
> 
> By using the following sort command to sort the input
> file due, the output due is showing as :
> 
> sort -dfi -k1.11,1.39 -odue due
> 
> 
> 
> 123180024 BIJJALA ESWARA RAO               1580.50
> 061233693 BIJJALA JANARDHAN RAO            2280.00
> 123812394 BIJJALA VENKATESWAR RAO          1682.50
> 123349123 BIRJALA JANARDHAN RAO            2794.20
> 123712310 B.KRISHNA MURTHY                 2362.50
> 123234123 B MUTHAIAH                       1727.00
> 038123230 B NAGESWAR RAO                   1625.00
> 121237123 BODA VIJAYA                      2827.00
> 041237267 BODDU APPAIAH                     485.60
> 123123361 BODDU SRINIVASA RAO              4540.00
> 012316123 BODDU VEERA SWAMY                1527.50
> 
> Sorting was on name order (i.e. position 11 to 39)
> After 4 records i.e after BIRJALA JANARDHAN RAO,
> we find B.KRISHNA MURTHY where as B.KRISHNA MUTHY,
> B MUTHAIAH, B NAGESWAR RAO come first in sorted
> order , kindly guide us.

Well there are a few things going on here.

-d will exclude '.' but include ' '

-f is redundant with -d as -d is a subset of -f (I think)

Also your locale make exclude punctuation chars from the search.
I.E. cause ' ' to be disregarded in the sort.

Now with -d, sort will not treat '.' and ' ' equivalently,
or sort in ASCII order. So you have 2 options I think:

  tr '.' ' ' < due | LANG=C sort -di -k1.11,1.39 > due.sorted

  LANG=C sort -i -k1.11,1.39 -o due due

The former will convert '.' to ' ',
while the latter will include non dictionary chars in the sort.

cheers,
Pádraig.




This bug report was last modified 13 years and 88 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.