Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Sorting according to locale collation

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


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

just out of curiosity: You said that "i" and "y" are treated the same. Would it still be right if you swap "ia" and "ya" in that list?

I'm not Lithuanian - i just studied it a little in the University. From what i've seen in dictionaries and grammar books, when the letter following I/Y is the same, I comes before Y.

Does the Unix utility sort(1) behave correctly?

I tried running this:

[root@sugarcube loc]# LC_COLLATE="lt_LT" [root@sugarcube loc]# export LC_COLLATE [root@sugarcube loc]# locale LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE=lt_LT LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL= [root@sugarcube loc]# cat ia.txt ia ic ib ya yb yc [root@sugarcube loc]# sort ia.txt ia ib ic ya yb yc

Looks like sort(1) did something, but not what i expected. I am not sure that i changed the locale correctly - i am not a Unix export. Any help will be appreciated.

Replies are listed 'Best First'.
Re^3: Sorting according to locale collation
by betterworld (Curate) on Apr 22, 2007 at 14:42 UTC

    Looks like sort(1) prints the lines in the same order as Perl's sort does. So I guess the problem is that the locale itself does not treat i and y the same. (I don't know if that's possible at all.)

    According to perldoc perllocale, the locale answers the question "which of these letters comes first". I don't think that the answer "neither i nor y comes first, but i comes first if it is the only difference in the whole word" is allowed.

Re^3: Sorting according to locale collation
by Krambambuli (Curate) on Apr 22, 2007 at 15:55 UTC
    What is the output if you add say

    ha
    ja

    to your test data set ?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2019-12-05 15:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (151 votes). Check out past polls.

    Notices?