Subject: bin/24756: /usr/bin/sort doesn't preserve field sort order
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <mlh@goathill.org>
List: netbsd-bugs
Date: 03/12/2004 10:57:43
>Number:         24756
>Category:       bin
>Synopsis:       /usr/bin/sort doesn't preserve field sort order
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 12 16:58:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     mlh
>Release:        NetBSD 1.6ZK
>Organization:
none
        
>Environment:
        
        
System: NetBSD enki.goathill.org 1.6ZK NetBSD 1.6ZK (GENERIC.MP) #0: Tue Mar 2 13:50:02 CST 2004 mlh@enki.goathill.org:/opt/obj/i386/opt/src/sys/arch/i386/compile/GENERIC.MP i386
Architecture: i386
Machine: i386
>Description:
When using field sorts with multiple field keys, /usr/bin/sort can 
apparently lose track of which is the primary sort field.
        
>How-To-Repeat:
        
Source file to be sorted - r2.out:
    5    36.00000
    6
         50.40000
    8    50.40000
    9    64.80000
   12    50.40000

$ sort -bt : -k1.6nr,1.17nr -k1.1nr,1.5nr r2.out
    9    64.80000
   12    50.40000
    8    50.40000
    5    36.00000   -- sorted out of order
         50.40000
    6            
$  sort -t : -k1.6bnr,1.17nr -k1.1nr,1.5nr r2.out
    9    64.80000
   12    50.40000
    8    50.40000
    5    36.00000   -- sorted out of order
         50.40000
    6
$ sort -t : -k1.6nr,1.17bnr -k1.1nr,1.5nr r2.out
    9    64.80000
         50.40000
   12    50.40000
    8    50.40000
    5    36.00000
    6
$ sort -t : -k1.6bnr,1.17bnr -k1.1nr,1.5nr r2.out
    9    64.80000
   12    50.40000
    8    50.40000
    5    36.00000   -- sorted out of order
         50.40000
    6

>Fix:
        

>Release-Note:
>Audit-Trail:
>Unformatted: