http://www.perlmonks.org?node_id=761305

Jorge_de_Burgos has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks. I wonder if any of you has tried to sort a list of names under a Spanish locale system. I find the output puzzling, and you can't blame it on my knowledge of Spanish since that's my native tongue.

I mean, whereas this all-English program:

#!/usr/bin/perl my @list = ('maceira', 'mac alister', 'mac loughlin', 'san esteban', ' +sangregorio', 'san zoilo'); print "$_\n" for sort @list;

outputs this (as expected in the default English perl dialect):

mac alister mac loughlin maceira san esteban san zoilo sangregorio
this supposedly Spanified program:
#!/usr/bin/perl use locale; my @list = ('maceira', 'mac alister', 'mac loughlin', 'san esteban', ' +sangregorio', 'san zoilo'); print "$_\n" for sort @list;
outputs this non-Spanish order:
mac alister maceira mac loughlin san esteban sangregorio san zoilo

Now please keep in mind that:

  1. I haven't used any high ASCII character in the list.
  2. My system locale is "es_AR.UTF-8".
  3. 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").