in reply to Move matched to top, bottom

This should do it .. read the comments backwards.
print join "\n", @rawentries[ # array slice to turn the indices back to the values (c +ould use map, too) sort { ($rawentries[$a] =~ /Endbit/i) <=> ($rawentries[$b] =~ m/Endbi +t/i) # sort first using the index's array value matching against a r +egex and sort against the return. non-matches go higher; matches go l +ower || $a <=> $b # default to just sorting the index values to + maintain order w/in bit/not-bit chunks } 0 .. $#rawentries # sort the indices ] ;
(note that this could be a good candidate for a schwartzian transform)