http://qs321.pair.com?node_id=314383


in reply to Sorting a subset

Try using grep, like so:
my @array = qw(Art bob joe andy willy Andrew john Archie); foreach(sort {substr($a,1) cmp substr($b,1)} grep /^A/, @array){ print "$_\n"; } __OUTPUT__ Andrew Archie Art
Update:You could also do it using substr instead of a regex. I'm not sure which on is more efficient.
foreach(sort {substr($a,1) cmp substr($b,1)} grep {substr($_,0,1) eq ' +A'} @array)

- Tom