http://qs1969.pair.com?node_id=11143075


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 );