in reply to
Re^3: Date to be sorted in descending and time in ascending
in thread Date to be sorted in descending and time in ascending
Yep. For further curiosity, I did a count on how many substr calls there were. For the ST, of course, you have two for each element, one to get the first 8 chars and one to get the rest. So for a million-element array, that's 2M calls. But for the sort-on-substr version, I got about 37M substr calls. That'll vary some depending on how unsorted the original array is, but that's probably a good ballpark number.
That's a lot more substr calls, but I guess it's still less work than building an entire new million-element array (with each element a reference to a two-element array), as the ST requires.
It does give me a (very rough) rule of thumb, though: for the ST to be more efficient, the alternative probably needs to do the equivalent of 8-10 substr calls. So just a few core functions probably won't qualify, but a longer series of functions, or some fairly complex regexes, or certainly any sort of file or database lookups, probably will. And there's always measurement to see for sure.
Available for small or large Perl jobs; see my home node.