Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: Sorting according to locale collation

by amir_e_a (Hermit)
on Apr 22, 2007 at 13:07 UTC ( #611359=note: print w/replies, xml ) Need Help??

in reply to Re: Sorting according to locale collation
in thread Sorting according to locale collation

Check what locale settings are installed/available to you in the working environment (perllocale suggests a number of ways to do that)

I tried `locale -a' on Linux, and found out that it doesn't have 'lt', but it does have lt_LT, which should be the same. (It also has 'lithuanian' ... Is it a standard in Unix or some GNU extension?)

Anyway, i tried running this:

use strict; use warnings; use locale; use POSIX; my $loc = setlocale(LC_ALL, 'lt'); if (defined $loc) { print "loc is defined\n"; print "loc value: *$loc*\n"; } else { print "loc is undefined\n"; } my @sorttest = qw(ia ib ic ya yb yc); for (sort @sorttest) { print "$_\n"; }

When i try 'lt_LT', $loc is 'lt_LT'. When i try 'lt', $loc is undefined, so i must be in the right direction.

However, the sorting still doesn't work as i would expect Can it really be a bug in Linux?

Also, perllocale suggests only Unix'ish ways to list available locales. Is there anything like `locale -a' on Windows? I'm trying to be portable.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://611359]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2023-03-20 18:19 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.