Skip to content

Instantly share code, notes, and snippets.

@rsms
Created January 10, 2019 20:37
Show Gist options
  • Save rsms/97c7c818cd98b11d38ea75078d2b5db2 to your computer and use it in GitHub Desktop.
Save rsms/97c7c818cd98b11d38ea75078d2b5db2 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