Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Spanish locale and name sorting

by Jorge_de_Burgos (Beadle)
on May 02, 2009 at 12:16 UTC ( #761488=note: print w/replies, xml ) Need Help??


in reply to Re^2: Spanish locale and name sorting
in thread Spanish locale and name sorting

Down and dirty hacks are available of course. For everyday use I have come up with this:

#!/usr/bin/perl use locale; my @list = ('maceira', 'mac alister', 'mac loughlin', 'san esteban', ' +sangregorio', 'san zoilo'); sub keeping_spaces { my $aa = $a; my $bb = $b; for ($aa) { tr/ /A/; } for ($bb) { tr/ /A/; } return $aa cmp $bb; } print "$_\n" for sort keeping_spaces @list;

Which outputs what we would expect:

mac alister mac loughlin maceira san esteban san zoilo sangregorio

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2023-02-02 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (17 votes). Check out past polls.

    Notices?