my %cache; my @sorted = sort {($cache{$a} ||= str2time($a)) <=> ($cache{$b} ||= str2time($b)) } @dates;