my @sorted_list = map { $_[0] } sort { date_compare($a[1],$b[1]) } # [1] is Date1, [2] is Date2, [3] is the type.asp map { [ $_, split /_/ ] } @list;