(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

use locale; use POSIX; setlocale(LC_ALL, 'lt');
... And then i run:
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.


In reply to Sorting according to locale collation by amir_e_a

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.