1 2 3 4 5 6 7
12345678901234567890123456789012345678901234567890123456789012345678901234567
sub by_priority{my$r=qr/^(?:Service|Organisation|FAQ)/;($a=~$r&&-1)+($b=~$r)}
####
# 1 2 3 4 5 6 7 8
#234567890123456789012345678901234567890123456789012345678901234567890123456789012345678
sub by_priority{my$r=qr/^(?:Service|Organisation|FAQ)/;($a=~$r&&-1)+($b=~$r)||$a cmp$b;}
####
#! perl -sw
use strict;
# 1 2 3 4 5 6 7 8
#23456789012345678901234567890123456789012345678901234567890123456789012345678901234567
sub by_priority{my$r=qr/^(?:Service|Organisation|FAQ)/;($a=~$r&&-1)+($b=~$r)||$a cmp$b}
my @stuff = qw/
the
Services_s
FAQ_A
quick
FAQ_C
Organisation_3
brown
FAQ_B
fox
Services_p
jumps
Services_q
Over
Organisation_1
A
lazy
Organisation_2
dog
/;
sub shufl (\@) {
my $r=pop;
$a = $_ + rand @{$r} - $_
and @$r[$_, $a] = @$r[$a, $_]
for (0..$#{$r});
}
shufl @stuff;
print $_,$/ for sort by_priority @stuff;
__END__
c:\test>test
FAQ_A
FAQ_B
FAQ_C
Organisation1
Organisation2
Organisation3
Servicesp
Servicesq
Servicess
A
Over
brown
dog
fox
jumps
lazy
quick
the
c:\test>