use strict; 
use warnings;

for ( 'shorter thelonger', 'abcd 123456789 abcdef 1234567' )
  {
  print "\nfor strings => $_\n";
  printf "length%d:%s\n", length(), $_
    for sort { length $b <=> length $a } split;
  }