Item14416: SpreadSheetPlugin LISTSORT doesn't correctly sort unicode - Needs to NFKD the strings.
Priority: Normal
Current State: Waiting for Release
Released In: 2.2.0
Target Release: minor
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