Skip to content

Instantly share code, notes, and snippets.

@ThomasRettig
Forked from rsms/uca.pl
Created January 18, 2022 14:28
Show Gist options
  • Save ThomasRettig/6665883df0701bcba8e06d20629897dd to your computer and use it in GitHub Desktop.
Save ThomasRettig/6665883df0701bcba8e06d20629897dd to your computer and use it in GitHub Desktop.
Unicode Collation Algorithm (sort)
use Unicode::Collate;
# https://metacpan.org/pod/Unicode::Collate
my @unsorted = ('A', "\xF0\x9F\x97\x91", 'B');
print "unsorted:\n";
foreach (@unsorted) {
print "$_\n";
}
my @sorted = Unicode::Collate->new()->sort(@unsorted);
print "-------------\n";
print "sorted:\n";
foreach (@sorted) {
print "$_\n";
}
unsorted:
A
🗑
B
-------------
sorted:
A
B
🗑
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment