NOTE: If you are a developer, please use a private wiki based on foswiki/trunk on a daily base ...or use trunk.foswiki.org to view this page for some minimal testing.
Use Item9693 for docu changes for 1.2 and 2.0.

Item1878: Numerical Sort in table columns broken

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Urgent Closed Extension TablePlugin Main.KennethLavrsen
Trying to sort a table column containing just numbers resulted in a textual sorting in a 1.0.6 installation.

Digging into the code, I managed to restrict the problem to what follows:
  • lib/Foswiki/Plugins/TablePlugin/Core.pm calls, in _convertToNumberAndDate, Foswiki::Time::parseTime with each row value as parameter
  • in lib/Foswiki/Time.pm, parseTime($date) returns 0 for each input value, but the regex at line 162 matches 2-digits numbers as years, and when $date reaches 60, it passes the following code at line 198:
    198         return 0 if ( defined($year) && $year < 60 );
    
    resulting in parseTime returning -315619200 instead of 0, and therefore breaking the sorting of the column, because the previous column values figured as numbers, and this specific one as a date.

Forcing the regex at line 162 to match exactly 4 digits instead of 2 or more allow the column to be sorted numerically.

Frankly I don't understand how allowing a 2-digit numbrer to match as a date could allow numerical sort to work in any way, given how differentiating between numbers and dates is implemented, but I suspect my understanding to be fairly incomplete.

-- FulvioScapin - 02 Aug 2009

Good analysis

It was a recent fix from June that goofed up normal number sorting.

I am fixing this. I have fix. Just need to update unit test.

-- KennethLavrsen - 02 Sep 2009

Fix checked in. New plugin uploaded. Unit test follows after a good night of sleep.

-- KennethLavrsen - 02 Sep 2009

ItemTemplate edit

Summary Numerical Sort in table columns broken
ReportedBy FulvioScapin
Codebase 1.0.6
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component TablePlugin
Priority Urgent
CurrentState Closed
WaitingFor KennethLavrsen
Checkins Foswikirev:4758 Foswikirev:4759 Foswikirev:4766 Foswikirev:4767
TargetRelease patch
ReleasedIn 1.0.7, 1.1.0
Topic revision: r8 - 20 Sep 2009, KennethLavrsen
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads