in reply to When does it pay to use the schwartzian transform?

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.

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.

Another way to get the do-it-only-once efficiency would be to Memoize (or cache the results from) the transformation function.

Caution: Contents may have been coded under pressure.