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' ];