http://www.perlmonks.org?node_id=1068115


in reply to Re: Sorting Vietnamese text
in thread Sorting Vietnamese text

Thanks - could you post a small code example? I've not quite sure how to create and reference the index.

Replies are listed 'Best First'.
Re^3: Sorting Vietnamese text
by Atacama (Sexton) on Dec 23, 2013 at 00:35 UTC
    moritz basically implemented a similar idea (that I formulated incorrectly in my message, btw). I think it will be better to use the unicode collation module advised above.
    #!/usr/bin/env perl use warnings; use strict; use Sort::External; use Unicode::Collate::Locale; my $in = shift // 'large-unsorted.txt'; my $out = shift // 'sorted.txt'; my $comparator = Unicode::Collate::Locale->new(locale =>'vi'); my $sorter = Sort::External->new ( sortsub => sub { $comparator->cmp($Sort::External::a, $Sort::Externa +l::b) } ); open my $unsorted, '<', $in or die $!; $sorter->feed($_) while <$unsorted>; $sorter->finish(outfile => $out);