Emanuel has asked for the wisdom of the Perl Monks concerning the following question:
this returns the following array:my @array; push @array, "one"; push @array, "two"; push @array, "three"; psuh @array, "four"; my $k=0; my @combos; for(combinations(@array)) { $combos[$k] = join("|",@$_); $k++; } sub combinations { return [] unless @_; my $first = shift; my @rest = combinations(@_); return @rest, map { [$first, @$_] } @rest; }
but what I need is to sort the array, so the return value is something like:$VAR1 = [ '', 'four', 'three', 'three|four', 'two', 'two|four', 'two|three', 'two|three|four', 'one', 'one|four', 'one|three', 'one|three|four', 'one|two', 'one|two|four', 'one|two|three', 'one|two|three|four' ];
any help regarding this would be greatly appreciated.$VAR1 = [ 'one|two|three|four' 'two|three|four', 'one|three|four', 'one|two|three', 'one|two|four', 'three|four', 'two|three', 'one|three', 'two|four', 'one|four', 'one|two', 'three', 'four', 'two', 'one', '' ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort Array by length of Value
by DrHyde (Prior) on Oct 06, 2003 at 14:34 UTC | |
by Emanuel (Pilgrim) on Oct 06, 2003 at 14:39 UTC | |
by shenme (Priest) on Oct 06, 2003 at 14:44 UTC | |
by kesterkester (Hermit) on Oct 06, 2003 at 14:42 UTC | |
|
Re: Sort Array by length of Value
by jmcnamara (Monsignor) on Oct 06, 2003 at 14:41 UTC | |
|
Re: Sort Array by length of Value
by flounder99 (Friar) on Oct 06, 2003 at 17:07 UTC | |
by Roger (Parson) on Oct 07, 2003 at 03:54 UTC |