bug#6972: bug in sorting floats (original) (raw)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
From: | Eric Blake |
---|---|
Subject: | bug#6972: bug in sorting floats |
Date: | Thu, 02 Sep 2010 11:35:19 -0600 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2 |
On 09/02/2010 03:25 AM, saddy wrote:
Hi, I want to sort a file by the 6th column:
test.txt
AvrBs2<- Fer2 -> XopE1 0.0844155844155844 ((1.1e+03)(1.1e+03)) AvrBs2<- UPF0302 -> XopE1 0 ((40)(5.2e+02)) AvrBs1<- Calc_CGRP_IAPP -> XopH 0.1 ((2.6e+02)(4.2e+02)) AvrBs2<- DUF3248 -> XopE1 0.0476190476190476 ((7.6e+02)(5.7e+02)) AvrBs2<- MIG-14_Wnt-bd -> XopE1 0 ((3.6e+03)(3.6e+03)) XopX<- Zw10 -> XopJ1 0.0218487394957983 ((1.6e+02)(7e+02)) XopX<- Zw10 -> XopJ2 0.019327731092437 ((1.6e+02)(1.7e+03)) AvrBs1<- 3H -> XopJ4 0.153061224489796 ((3.4e+02)(25)) AvrBs2<- Ubiq_cyt_C_chap -> XopE1 0 ((7.6e+02)*(1.8e+03))
Thanks for the report. However, I fail to see what you are trying to do in the first place, to state whether the issue is a problem in your usage of sort (likely) or a bug in sort itself (less likely, but it has been known to happen). Exactly what order are you expecting? Column 6 is not a floating point number, but an arithmetic expression, so asking to sort by column 6 doesn't really make sense to me. Using the new (post-8.5) sort --debug feature is telling:
$ sort --debug -k6g test.txt sort: using `en_US.UTF-8' sorting rules sort: key 1 is numeric and spans multiple fields AvrBs1<- 3H -> XopJ4 0.153061224489796 ((3.4e+02)*(25)) ^ no match for key
...
Did you mean sorting by column 5, as in 0.153061224489796, in which case you should be using -k5,5g?
Or are you actually trying to sort by the value that would be computed if you performed floating point arithmetic on the expressions, such as ((3.4e+02)*25)) sorting equivalent to 85.0? Sort does not support performing math on a sort column, and I don't think that is a feature that anyone has ever been clamoring for; to sort by a computed value, you'd have to run the computation independently.
-- Eric Blake address@hidden +1-801-349-2682 Libvirt virtualization library http://libvirt.org
- bug#6972: bug in sorting floats, saddy, 2010/09/02
- bug#6972: bug in sorting floats, saddy, 2010/09/02
- bug#6972: bug in sorting floats,Eric Blake <=
* Message not available
* bug#6972: bug in sorting floats, Eric Blake, 2010/09/02
- Prev by Date:bug#6972: bug in sorting floats
- Next by Date:bug#6972: bug in sorting floats
- Previous by thread:bug#6972: bug in sorting floats
- Next by thread:bug#6972: bug in sorting floats
- Index(es):