in reply to Complex Sort - using varying numbers of parameters
Following code seems to work for me:
This could be optimized to return from 0..5 loop earlier, and sub could be inlined, but let's do this another time.my @arr = map {[split /\s+/]} <DATA>; sub criteria { my $r = 0; $r ||= (($a->[$_]||0) <=> ($b->[$_]||0)) for 0..5; $r; } @arr = sort {criteria} @arr; print join "\n", map {join " ", @$_} @arr; __DATA__
Courage, the Cowardly Dog
|
---|
In Section
Seekers of Perl Wisdom