amir_e_a has asked for the wisdom of the Perl Monks concerning the following question:
(This message uses special characters, which may be displayed incorrectly on your system:
Thanks for understanding.)
Hi,
I'm writing a Perl program that processes a text in the Lithuanian language.
Lithuanian uses the Latin alphabet with some modifications. One of the curious properties of this language is the alphabetic order. There are three variations of the letter I: I, Y and Į (the last one is supposed to look like an I with a tail). They are considered as one and the same letter when words are sorted alphabetically, so the Y doesn't come between X and Z and not even between I and J, but is mixed with I. For example, the following list is taken straight from a dictionary. :
As you see, these words are sorted as if they were all written with an I.
As far as i understand, Perl's sort function uses the locale to determine the collation order. I'm trying to set a Lithuanian locale by saying
... And then i run:use locale; use POSIX; setlocale(LC_ALL, 'lt');
my @sorttest = qw(ia ib ic ya yb yc); for (sort @sorttest) { print "$_\n"; }
According to Lithuanian rules this should have printed:
ia
ya
ib
yb
ic
yc
... but instead it prints:
ia
ib
ic
ya
yb
yc
Am i doing something wrong? Or maybe Perl just doesn't know about the different locales? Or maybe Perl is supposed to know, but it is a bug?
I tried the above code with ActivePerl 5.8.8 build 820 on Windows XP SP2 and with Perl 5.8.0 on Red Hat Enterprise Linux kernel 2.4.21 (i'm not sure which version of RHEL exactly it is). The results were the same.
Thanks in advance for any help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting according to locale collation
by Krambambuli (Curate) on Apr 22, 2007 at 11:54 UTC | |
by amir_e_a (Hermit) on Apr 22, 2007 at 13:07 UTC | |
|
Re: Sorting according to locale collation
by Krambambuli (Curate) on Apr 22, 2007 at 16:38 UTC | |
|
Re: Sorting according to locale collation
by betterworld (Curate) on Apr 22, 2007 at 12:00 UTC | |
by amir_e_a (Hermit) on Apr 22, 2007 at 13:40 UTC | |
by betterworld (Curate) on Apr 22, 2007 at 14:42 UTC | |
by Krambambuli (Curate) on Apr 22, 2007 at 15:55 UTC | |
by Anonymous Monk on Dec 06, 2011 at 01:30 UTC |