that takes $_ (each item of the list in turn) and produces the corresponding value that is to be compared in its stead. Reading from right to left (or from the bottom to the top): the original list @unsorted is fed into a map operation that wraps each item into a (reference to an anonymous 2-element) array consisting of itself and the calculated value that will determine its sort order (list of item becomes a list of [item, value]); then the list of lists produced by map is fed into sort, which sorts it according to the values previously calculated (list of [item, value] ⇒ sorted list of [item, value]); finally, another map operation unwraps the values (from the anonymous array) used for the sorting, producing the items of the original list in the sorted order (sorted list of [item, value] ⇒ sorted list of item). The use of anonymous arrays ensures that memory will be reclaimed by the Perl garbage collector immediately after the sorting is done. Efficiency analysis Without the Schwartzian transform, the sorting in the example above would be written in Perl like this: @sorted = sort { foo($a) cmp foo($b) } @unsorted; While it is shorter to code, the naive approach here could be much less efficient if the key function (called in the example above) is expensive to compute. This is because the code inside the brackets is evaluated each time two elements need to be compared. An optimal comparison sort performs O(n log n) comparisons (where n is the length of the list), with 2 calls to every comparison, resulting in O(n log n) calls to . In comparison, using the Schwartzian transform, we only make 1 call to per element, at the beginning stage, for a total of n calls to . However, if the function is relatively simple, then the extra overhead of the Schwartzian transform may be unwarranted. Example For example, to sort a list of files by their modification times, a naive approach might be as follows: function naiveCompare(file a, file b) { return modificationTime(a) < modificationTime(b) } // Assume that sort(list, comparisonPredicate) sorts the given list using // the comparisonPredicate to compare two elements. sortedArray := sort(filesArray, naiveCompare) Unless the modification times are for each file, this method requires re-computing them every time a file is compared in the sort. Using the Schwartzian transform, the modification time is calculated