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


in reply to Date to be sorted in descending and time in ascending

The basic technique for sorting on multiple columns in a set of records (an array of arrays) is:

my $primary_sort_column = n; my $secondary_sort_column = n; my $tertiary_sort_column = n; my @sorted_records = sort { $a->[$primary_sort_column] op $b->[$primary_sort_column]; || $a->[$secondary_sort_column] op $b->[$secondary_sort_column]; || $a->[$tertiary_sort_column] op $b->[$tertiary_sort_column]; ) @unsorted_records;

n is an integer; op is typically cmp (lexical ordering) or the spaceship operator <=> (numeric ordering)

Take a look at sort for details.

-- Ken