• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7700 for generic doc work for TWiki-6.0.2. Use View topic Item7703 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item6405: Table sorting incorrect for numbers with decimal places

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension TablePlugin Normal Closed   patch 5.0.0

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

According to the TablePlugin docs:

The type of data in the cell is determined automatically:

  • date if format is:
    • dd MMM YYYY - hh:mm (MMM is Jan, Feb, etc.)
    • dd-MMM-YY or dd-MMM-YYYY (can be / or space in place of -) (MMM is Jan, Feb, etc)
  • number is digits, with optional decimal point
  • otherwise treated as text
However, the following data is not sorted correctly.

%TABLE{sort="on" initsort="1"}%
| *number* |
| 1 |
| 10.1 |
| 9.99 |
| 2 |
| 2.0 |
| 20 |

numberSorted ascending
1
2
2.0
9.99
10.1
20

-- TWiki:Main/VickiBrown - 08 Mar 2010

Fixed, in SVN trunk and 4.3 branch. Patch:

Index: lib/TWiki/Plugins/TablePlugin/Core.pm
===================================================================
--- lib/TWiki/Plugins/TablePlugin/Core.pm   (revision 18367)
+++ lib/TWiki/Plugins/TablePlugin/Core.pm   (working copy)
@@ -1,7 +1,7 @@
 # Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/
 #
 # Copyright (C) 2001-2003 John Talintyre, jet@cheerful.com
-# Copyright (C) 2001-2004 Peter Thoeny, peter@thoeny.org
+# Copyright (C) 2001-2010 Peter Thoeny, peter@thoeny.org
 # Copyright (C) 2005-2006 TWiki Contributors
 #
 # This program is free software; you can redistribute it and/or
@@ -533,19 +533,13 @@
         $year += 2000 if ( length($year) == 2 );
         $date = timegm( 0, 0, 0, $1, $mon2num{$2}, $year - 1900 );
     }
-    elsif ( $text =~ /^\s*([0-9]+)(\.([0-9]))*(.?)*$/ ) {
+    elsif ( $text =~ /^\s*(([0-9]+)(\.([0-9]))?).*$/ ) {
 
         # for example for attachment sizes: 1.1 K
         # but also for other strings that start with a number
-        my $num1 = $1 || 0;
-        my $num2 = $2 || 0;
-        $num = scalar("$num1$num2");
+        $num = $1;
     }
-    elsif ( $text =~ /^\s*[0-9]+(\.[0-9]+)?\s*$/ ) {
 
-        $num = $text;
-    }
-
     return ( $num, $date );
 }

-- TWiki:Main.PeterThoeny - 09 Mar 2010

Also updated plugin package at TWiki:Plugins/TablePlugin

-- TWiki:Main.PeterThoeny - 09 Mar 2010

ItemTemplate
Summary Table sorting incorrect for numbers with decimal places
ReportedBy TWiki:Main.VickiBrown
Codebase 4.3.2, ~twiki4
SVN Range TWiki-5.0.0, Sun, 07 Mar 2010, build 18385
AppliesTo Extension
Component TablePlugin
Priority Normal
CurrentState Closed
WaitingFor

Checkins TWikirev:18386 TWikirev:18387
TargetRelease patch
ReleasedIn 5.0.0
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2010-05-31 - PeterThoeny
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback