use Sort::Key qw(ikeysort); my @unordered = (qw/very_long short/); my @ordered = ikeysort { length } @unordered;