This project is archived and is in readonly mode.

#162 ✓resolved
Daniele C.

HtmlTable.Sort: Float parser strange behaviour

Reported by Daniele C. | October 26th, 2009 @ 08:20 AM | in 1.2.4.2 (closed)

I've notice that the float parser does not work properly with numbers of different decimal lengths (for example the sorting say 29.424122 is more than 51.50714). Moreover, parsing with negative numbers does not work. You can see it at

http://mooshell.net/2wMrb/

(I've insered the fix for the push method because it's not officialy insered)

I think the problem is that to perform the sort order is used the standard array sort method for string. To allow number sort the script add 0 at the begin of the number in order to normalize ot as string.

For example:

23
100

become:

00000000000000000000000000000023
00000000000000000000000000000100

so a literal order work. But for decimal numer this does not work:

29.424122
51.50714

become:

0000000000000000000000029.424122
00000000000000000000000051.50714

and of course the first is literally more than the second.

It could be a solution to use the parameter of the Array.sort method passing a function that controls the type of the value that is sorting and perform the right comparison.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The MooTools Extensions

People watching this ticket

Pages