[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Surprising bug in sort
From: |
Tim_Ryan |
Subject: |
Surprising bug in sort |
Date: |
Mon, 18 Aug 2008 15:11:29 +1200 |
Hi there,
I ran into a very surprising bug in the Windows cygwin sort routine:
I'm running GNU coreutils 6.9.92.4-f088d-dirtJanuary 2008 on Windows XP
Service Pack 2.
Using the source data:
2008-08-17 14:09:13,816 [RMI TCP Connection(5)-10.67.16.134] INFO
bnz.ib.util.logging.MethodEntryExitLogger - Starting
2008-08-17 14:09:15,676 [RMI TCP Connection(5)-10.67.16.134] INFO
bnz.ib.util.logging.MethodEntryExitLogger - Exiting
2008-08-17 14:09:16,806 [RMI TCP Connection(4)-10.67.16.134] INFO
bnz.ib.util.logging.MethodEntryExitLogger - Starting
2008-08-17 14:09:16,806 [RMI TCP Connection(4)-10.67.16.134] INFO
bnz.ib.util.logging.MethodEntryExitLogger - Exiting
2008-08-17 14:09:16,949 [RMI TCP Connection(5)-10.67.16.134] INFO
bnz.ib.util.logging.MethodEntryExitLogger - Starting
2008-08-17 14:09:16,955 [RMI TCP Connection(5)-10.67.16.134] INFO
bnz.ib.util.logging.MethodEntryExitLogger - Exiting
2008-08-17 14:09:17,141 [RMI TCP Connection(5)-10.67.16.134] INFO
bnz.ib.util.logging.MethodEntryExitLogger - Starting
2008-08-17 14:09:17,141 [RMI TCP Connection(5)-10.67.16.134] INFO
bnz.ib.util.logging.MethodEntryExitLogger - Exiting
If I use the sort command:
sort --stable -k2 -k9r
the data is not sorted correctly - the two pairs of lines containing the
same timestamp (14:09:16,806, and 14:09:17,141) are incorrectly reversed
in order so that the Exiting line comes before the Starting line - despite
the -k9r sort key.
In fact I shouldn't even need the -k9r key as I am using --stable, but the
sort reverses the two pairs of lines regardless.
I found a workaround... if I make no changes to the data, but use the sort
command:
sort --stable -k1,2 -k9r
then the data is sorted correctly - adding the date as the high-order part
of the time key somehow corrects the behaviour.
Regards,
Tim
Tim Ryan
Technical Consultant
Development Centre, Business Technology Services
Bank of New Zealand
DDI: +64 4 4746836
Mobile: +64 29 4746836
CAUTION - This message may contain privileged and confidential information
intended only for the use of the addressee named above. If you are not the
intended recipient of this message you are hereby notified that any use,
dissemination, distribution or reproduction of this message is prohibited.
This email was sent by the Bank of New Zealand. You can contact us on
0800 ASK BNZ (0800 275 269). Any views expressed in this message are those
of the individual sender and may not necessarily reflect the views of Bank
of New Zealand.
- Surprising bug in sort,
Tim_Ryan <=