in reply to Move matched to top, bottom

As per davidrw's suggestion, here is a Schwartzian Transform to do the same thing.

use strict; use warnings; my @rawentries = ( "1topEndbit", "2ndbit", "endBit3", "4thbit", "5thbit", "6OtherEndbit", "7Bitsecondfromend", "8Bitoneoffend", "9Anyoldbit"); print map {"$_->[0]\n"} sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] } map { [ $rawentries[$_], $rawentries[$_] =~ /Endbit/i ? 1 : 0, $_ ] } 0 .. $#rawentries;

When run it produces

2ndbit 4thbit 5thbit 7Bitsecondfromend 8Bitoneoffend 9Anyoldbit 1topEndbit endBit3 6OtherEndbit

Cheers,

JohnGG