in reply to Re: Get most recent data based on a date from an array of hashes.
in thread Get most recent data based on a date from an array of hashes.
Technically, if you only need to transform the date into a sortable key, you can just fudge the maths behind it to make it faster.
Say, the original date is MM-DD-YYYY (one of the most useless date formats available to modern computing), you could do something like this:
my $timestamp = '03-21-2021'; my ($month, $day, $year) = split/\-/, $timestamp; my $sortkey = $day + ($month * 100) + $year * 10000;
Now that the thing is an integer, you can compare numerically, which is faster than a string compare.
|
|---|