http://www.perlmonks.org?node_id=179444


in reply to Complex Sort - using varying numbers of parameters

Following code seems to work for me:
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__
This could be optimized to return from 0..5 loop earlier, and sub could be inlined, but let's do this another time.

Courage, the Cowardly Dog