[datatable-help] sorting on a floating point column

frederik at ofb.net frederik at ofb.net
Wed Jan 27 21:40:13 CET 2016


This is following up on a thread from a couple years ago:

http://lists.r-forge.r-project.org/pipermail/datatable-help/2013-May/001689.html

I ran into this problem myself, it took a bit of time to debug because
it is so surprising.

In my case, I was using order() to sort a list of floats.

I expected the result to be monotonic but it wasn't!

Then I found out that the problem was due to 'order' being part of the
data.table library. By using base::order, I was able to get correct
behavior.

I don't understand why improperly ordering floating point data helps
the data.table library accomplish anything, whether it is looking up
keys or what.

Also, it must be much slower to compare floats with a tolerance, than
to just compare them. I seem to recall that floats were designed so
that normal comparison is quite fast.

Please fix this bug, or at least document it more visibly.

Thank you,

Frederick Eaton


More information about the datatable-help mailing list