in reply to Re: Efficient Grouping
in thread Efficient Grouping

Just to clarify, this
push (@G1_out, $input) if grep($_ eq $prefix, @Group1);
is a bad idea. It's much slower than the original.

The hash solutions offered by davorg or tommyw are good except if the possibility exists that the groups are not disjoint. The example given did not overlap, but he did not explicitly say it was impossible.