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


in reply to sorting array of arrays reference

Use Sort::Key::Top which implements the Selection Algorithm:
use Sort::Key::Top qw(rikeytopsort); my @sorted = rikeytopsort { $_->[2] } 3 => @masterArray; # rikeytopsort means... # r => reverse (descending) order # i => the key is an integer # key => use a key extraction block # top => get the top n elements # sort => sorted