#! perl -sw use strict; # 1 2 3 4 5 6 7 8 #234567890123456789012345678901234567890123456789012345678901234567890123456789012345 sub by_priority{my$r=qr/^(?:Service|Organisation|FAQ)/;$a cmp$b|($a=~$r&-1)+($b=~$r)} 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 the lazy Organisation_2 dog /; print $_,$/ for sort by_priority @stuff; __END__ c:\test>test FAQ_A FAQ_B FAQ_C Organisation_1 Organisation_2 Organisation_3 Services_p Services_q Services_s brown dog fox jumps lazy over quick the the c:\test>