note
Roy Johnson
Sorting is an O(n log n) operation, so the comparison sub gets called on average more than once for each element of the list being sorted. So if you have some sort of transformation to do to the data, you're going to be doing it multiple times for at least some of the elements if you include the transformation in the comparison sub.
<p>
If the transformation is expensive relative to building an arrayref and dereferencing it, the ST will give you gains in efficiency as the number of elements to be sorted increases, because you do the transformation exactly once per element.
<p>
Another way to get the do-it-only-once efficiency would be to [mod://Memoize] (or cache the results from) the transformation function.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-300037">
<hr>
<small><b>Caution:</b> Contents may have been coded under pressure.</small>
</div></div>
517329
517329