in reply to Sort Array by length of Value
outputs:use strict; use Data::Dumper; my @array = ( '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' ); @array = map {$_->[1]} sort {$b->[0] <=> $a->[0]} map {[length($_), $_]} @array; print Dumper(\@array);
$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' ];
--
flounder
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sort Array by length of Value
by Roger (Parson) on Oct 07, 2003 at 03:54 UTC |