On Oct 3, 2005, at 17:35, JupiterHost.Net wrote:
I need to sort them so they are in order of Q, B , then Z
The real array will have between 1 to 100 items, just FYI
They all go in ASCII relative order except B <-> Q, thus a way to get
it is to handle that special case and delegate to cmp the rest:
my @sorted = sort {
my $x = substr($a, 0, 1) . substr($b, 0, 1);
$x eq "BQ" || $x eq "QB" ? $b cmp $a : $a cmp $b;
} @array;
I used the concatenation for clarity, you see the idea anyway if
that's too expensive for your usage.
-- fxn
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>