#! perl -slw use strict; my @order = ( 0 .. 9, 'B'..'D', 'F'..'H', 'J'..'N', 'P'..'T', 'V'..'Z', 'b'..'d', 'f'..'h', 'j'..'n', 'p'..'t', 'v'..'z', 'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u', 'CH', 'SH', 'TH', 'WH', 'ch', 'sh', 'th', 'wh', ); my $re = join '|', sort{ length $b <=> length $a } @order; my $n = 0; my %map = map{ $_ => chr( $n++ ) } @order; sub trans { my $in = shift; $in =~ s[($re)]{ $map{ $1 } }ge; return $in; } chomp( my @data = map{ split ' ' } ); my @sorted = sort{ trans( $a ) cmp trans( $b ) } @data; print for @sorted; __DATA__ I've been asked to help with a project involving some Lao script. I need to alphabetize lists of words in Lao. However, Lao characters are only barely defined in Perl, e.g. \p{InLao} to identify a Lao character, and I have been unable to find a predefined localedef or similar for Lao. Searching perlmonks revealed virtually nothing on localedef, and as it turns out, perl may use it, but it seems to come from a C library. It appears a new Lao alphabet routine is needed. I may have to generate the rules for alphabetizing...here's the tough part: Lao is not a typical job for an alphabetic sort. Lao words are first sorted by consonant order. Vowels follow consonants in terms of alphabetical order, but not necessarily in terms of chronological order. For example, some vowels appear before the consonant even though they are pronounced after the consonant, and the alphabetical order follows pronunciation. After the typical list of single-character consonants, Lao has some "diphthong" consonants (double-character ones) which have their own alphabetical placements. All of this adds up to a challenging puzzle for a perl enthusiast. I welcome your thoughts on how this could be done, and/or how it should be done in a way that would follow standard practice and be able to serve the entire Perl community for Lao script. I have already developed a "Lao.pm" module (not yet submitted to CPAN, and may need to use a different namespace) that will identify Lao characters by consonant, vowel, punctuation, and tone marks, and will further classify the consonants by their Lao classes (high/mid/low). So I have the tools for distinguishing at the character level, e.g. \p{Lao::InLaoCons}\p{Lao::InLaoTone}\p{Lao::InLaoVowel}, but need to map the characters to an alphabetical order, and this part seems beyond my experience.