Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Changing ASCII collating sequence for sort

by vr (Curate)
on Apr 19, 2022 at 07:53 UTC ( #11143075=note: print w/replies, xml ) Need Help??

in reply to Changing ASCII collating sequence for sort

With Unicode::Collate (core module), only non-alphanumeric ordering has to be overridden. For task at hand, both full character names and quaternary weights could be simply omitted. Same about using asterisk instead of dot in element description; with dot, "variable" parameter wouldn't be necessary. However, seemingly "extra" work will, hopefully, help with vaguely looming further adjustments/customizations in the future.

use strict; use warnings; use feature 'say'; use Unicode::Collate; use charnames ''; my $punctuation_order = ' .,-;:!?"\'`_#$%&*+/|=@\^~()<>[]{}'; my $weight_base = 0x101; my $collator = Unicode::Collate-> new( upper_before_lower => 1, variable => 'non-ignorable', entry => join '', map { sprintf "%04X ; [*%04X.0020.0002.%04X] # %s\n", ord, $weight_base ++, ord, charnames::viacode( ord ) } split '', $punctuation_order ); my @list = qw{ }; # skipped say for $collator-> sort( @list );

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11143075]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2022-08-15 05:46 GMT
Find Nodes?
    Voting Booth?

    No recent polls found