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":



  • 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.