Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
We Spanish-speaking people would expect the sorted list to come out with all "mac something" and all "san something" before "maceira" and "sangregorio" respectively, making these longer words come out after surnames whose first word is shorter ("mac" and "san").

Maybe you expect wrong thing?

#!/usr/bin/perl -- use strict; use warnings; localsort("C"); localsort("Spanish - Argentina"); sub localsort { use POSIX qw(setlocale LC_CTYPE); my( $wantlocale ) = @_; my $curlocale = setlocale(LC_CTYPE); my $setlocale = setlocale(LC_CTYPE,$wantlocale); if( not $setlocale ){ print "Couldn't switch locale from ($curlocale) to ($wantlocal +e).\n"; } else { print "Current locale is ($setlocale).\n"; my @list = ('maceira', 'mac alister', 'mac loughlin', 'san esteban', 'sangregorio', 'san zoilo'); my @yes = do { use locale; sort @list; }; my @no = do { no locale; sort @list; }; printf " %-20s %-20s %-20s\n", qw[unsorted use-locale no-lo +cale ]; print '- ' x 33,"\n"; for my $i( 0 .. $#list ){ printf "%3d %-20s %-20s %-20s\n", $i, $list[$i], $yes[$i], + $no[$i]; } } print '- ' x 33,"\n"; setlocale(LC_CTYPE,$curlocale);#restore } __END__ Current locale is (C). unsorted use-locale no-locale - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 maceira mac alister mac alister 1 mac alister mac loughlin mac loughlin 2 mac loughlin maceira maceira 3 san esteban san esteban san esteban 4 sangregorio san zoilo san zoilo 5 san zoilo sangregorio sangregorio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Current locale is (Spanish_Spain.1252). unsorted use-locale no-locale - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 maceira mac alister mac alister 1 mac alister mac loughlin mac loughlin 2 mac loughlin maceira maceira 3 san esteban san esteban san esteban 4 sangregorio san zoilo san zoilo 5 san zoilo sangregorio sangregorio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

In reply to Re: Spanish locale and name sorting by Anonymous Monk
in thread Spanish locale and name sorting by Jorge_de_Burgos

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2023-03-29 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (70 votes). Check out past polls.

    Notices?