@in = ( ['the cat sat'], ['the ', 'cat', 'sat'], ['the cat', 'sat'], ['the', 'cat', 'sat'], ); { local $" = ''; @out = sort { "@$b" cmp "@$a" } @in; } use Data::Dumper; # munge the output for compactness and to make it look nicer $Data::Dumper::Indent = 0; print map {s/\[/\n \[/g; $_} Dumper \@out; __DATA__ $VAR1 = [ ['the','cat','sat'], ['the ','cat','sat'], ['the cat','sat'], ['the cat sat']];