bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11516: sort order


From: Pádraig Brady
Subject: bug#11516: sort order
Date: Sat, 19 May 2012 11:31:22 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]