You are here: Foswiki>Tasks Web>Item14416 (30 Sep 2017, GeorgeClark)Edit Attach

Item14416: SpreadSheetPlugin LISTSORT doesn't correctly sort unicode - Needs to NFKD the strings.

pencil
Priority: Normal
Current State: Waiting for Release
Released In: 2.2.0
Target Release: minor
Applies To: Extension
Component: I18N, SpreadSheetPlugin
Branches: Item14414
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
Found this while trying to sort a user list - non-ASCII ends up at the very end.

Borrowed the improved sort algorithm from MichaelDaum's changes to RCSStoreContrib.

diff --git a/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm b/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm
index 7de7517..5217bef 100644
--- a/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm
+++ b/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm
@@ -13,6 +13,7 @@ use warnings;
 use HTML::Entities;
 use Time::Local;
 use Time::Local qw( timegm_nocheck timelocal_nocheck );    # Necessary for DOY
+use Unicode::Normalize;
 
 # =========================
 my $web;
@@ -1101,7 +1102,7 @@ sub _LISTSORT {
         @arr = sort { $a <=> $b } @arr;
     }
     else {
-        @arr = sort @arr;
+        @arr =  map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, NFKD($_) ] } @arr;
     }
     return _listToDelimitedString(@arr);
 }

-- GeorgeClark - 07 Jun 2017

 

ItemTemplate edit

Summary SpreadSheetPlugin LISTSORT doesn't correctly sort unicode - Needs to NFKD the strings.
ReportedBy GeorgeClark
Codebase 2.1.4, trunk
SVN Range
AppliesTo Extension
Component I18N, SpreadSheetPlugin
Priority Normal
CurrentState Waiting for Release
WaitingFor
Checkins distro:6cda2e6463d9
TargetRelease minor
ReleasedIn 2.2.0
CheckinsOnBranches Item14414
trunkCheckins
masterCheckins
ItemBranchCheckins distro:6cda2e6463d9
Release02x01Checkins
Release02x00Checkins
Release01x01Checkins
Topic revision: r3 - 30 Sep 2017, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy