[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in 'sort': negative numbers in non-first key
From: |
Simon Anders |
Subject: |
Bug in 'sort': negative numbers in non-first key |
Date: |
Thu, 14 Sep 2006 11:19:42 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8.0.5) Gecko/20060726 Red Hat/1.0.3-0.el4.1 SeaMonkey/1.0.3 |
Hi,
either I misunderstand the documentation, or there is a subtle bug in
sort, when used with option '-g'.
As the minus sign ('-') has an ASCII value higher than the digits,
negative numbers end up after the positive ones, when using lexical (not
numerical) sort:
$ sort -g
[IN ] 2
[IN ] -3
[OUT] -3
[OUT] 2
Using the option "-g" gives the correct result, of course:
$ sort -g
[IN ] 2
[IN ] -3
[OUT] -3
[OUT] 2
However, when two keys are present, this fails to work:
$ sort -g
[IN ] 5 2
[IN ] 5 -3
[OUT] 5 2
[OUT] 5 -3
For only positive values, there is no problem:
$ sort -g
[IN ] 5 2.5
[IN ] 5 1.5
[OUT] 5 1.5
[OUT] 5 2.5
Is this a bug?
The examples above have been produced with sort from coreutils 5.2.1 on
RedHat Linux:
$ sort --version
sort (coreutils) 5.2.1
Written by Mike Haertel and Paul Eggert.
Copyright (C) 2004 Free Software Foundation, Inc.
[...]
$ rpm -q coreutils
coreutils-5.2.1-31.4
$ uname -a
Linux dopey.uibk.ac.at 2.6.9-42.0.2.ELsmp #1 SMP Thu Aug 17
18:00:32 EDT 2006 i686 i686 i386 GNU/Linux
Best regards,
Simon Anders
--
+---
| Simon Anders, Dipl. Phys.
| Institut fuer Theoretische Physik, Universitaet Innsbruck, Austria
| Tel. +43-512-507-6207, Fax -2919
| preferred (permanent) e-mail: address@hidden
- Bug in 'sort': negative numbers in non-first key,
Simon Anders <=