foreach(sort {substr($a,1) cmp substr($b,1)} grep {substr($_,0,1) eq 'A'} @array)