SID-00800: How to sort numbers in scientific notation in a table plugin
| Status: |
Answered |
TWiki version: |
4.2.0 |
Perl version: |
|
| Category: |
TablePlugin |
Server OS: |
redhat linux 7.2 |
Last update: |
16 years ago |
I am using the table plugin and have some columns of numbers that are in scientific notation (like 4.0392e-02, 3.9421e+01, etc.) The current sort will treat these as text and not sort them properly. Is there a way to handle the sorting of this notation?
--
JimKulikowski - 2010-03-29
Discussion and Answer
You should be able to do this by creating a sort key and then hiding it from view. See
SearchOrderOnMoreColumns for related information.
In your case, you might be able to simply convert scientific notation to decimal to get a sortable key. But if the exponents are too large you will get overflow problems. In that case, a sortable key could be constructed by reversing the parts: for your examples above, +01E3.9421 > -02E4.0392. If the bases are signed too, then you need another +/- prefix.
--
SeanCMorgan - 2010-03-29
The
TablePlugin could be enhanced to support sorting of numbers in scientific notation. If you are a programmer you could provide a patch. In any case, feel free to submit an enhancement request at
Bugs:TablePlugin
.
--
PeterThoeny - 2010-03-29
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.