Unicode sorting

Juan Manuel Clavero Almirón <[email protected]>
Newsgroups gmane.comp.otrs.devel
Message-ID <4E6C4135180B424CBFC6C6DE9456154A48FA788B@SCPDPSEXMB02P.ssib.local>
Hi all,

since OTRS 3.1, OTRS works internally with Unicode Strings but leaves character sorting to basic perl 'cmp', which is not really unicode aware...

as explained in Perl Unicode Cookbook [http://www.perl.com/pub/2012/06/perlunicook-case--and-accent-insensitive-sorting.html], I think it would be best to use Unicode::Collate's sort.

I've done this in Layout.pm -> _BuildSelectionDataRefCreate and it really has improved usability to our users (agents and customers both). This is the diff to the OTRS layout.pm (v 1.381.2.11 2012/06/22), in case anyone wants to use it:

    16a17,22
    > #####################
    > ## Unicode Sorting ##
    > #####################
    > use Unicode::Collate; 
    > #####################
    >
    4667a4674,4684
    > #####################
    > ## Unicode Sorting ##
    > #####################
    >         ## Unicode Sorting: added sorting by Unicode::Collate
    >         my $Collate = Unicode::Collate->new(level => 1);
    >         # Level 1 ignores case and diacritics
    >         # Level 2 adds diacritic comparisons to the ordering algorithm.
    >         # Level 3 adds case ordering.
    >         # Level 4 adds a tiebreaking comparison of probably more detail than most people will ever care to know.
    >         # Level 4 is default
    >
    4677c4694,4695
    <             @SortKeys = sort( keys %{ $Param{Data} } );
    ---
    >             ## Unicode Sorting ##
    >             @SortKeys = $Collate->sort( keys %{ $Param{Data} } );
    4686c4704,4705
    <             @SortKeys = sort { $SortHash{$a} cmp $SortHash{$b} } ( keys %SortHash );
    ---
    >             ## Unicode Sorting ##
    >             @SortKeys = sort { $Collate->cmp($SortHash{$a}, $SortHash{$b}) } ( keys %SortHash );
    4696c4715,4716
    <             push @SortKeys, sort { $List{$a} cmp $List{$b} } ( keys %List );
    ---
    >             ## Unicode Sorting ##
    >             push @SortKeys, sort { $Collate->cmp($List{$a}, $List{$b}) } ( keys %List );
    4702a4723
    >             ## Unicode Sorting ##
    4704c4725
    <                 = sort { $Param{Data}->{$a} cmp $Param{Data}->{$b} } ( keys %{ $Param{Data} } );
    ---
    >                 = sort { $Collate->cmp($Param{Data}->{$a}, $Param{Data}->{$b}) } ( keys %{ $Param{Data} } );
    4706a4728
    > #####################


Kind regards,
Juan Clavero

_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.