Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: Spanish locale and name sorting

by Jorge_de_Burgos (Beadle)
on May 02, 2009 at 12:16 UTC ( [id://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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-07-25 20:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.