http://qs321.pair.com?node_id=476793


in reply to Re^2: What is "Schwartzian Transform"
in thread What is "Schwarzian Transform" (aka Schwartzian)

The usual use is when the sort key must be derived from the data using a process that takes significant time/resources. The idea of the ST is to precalculate all of the sort keys before the sort operation so you only spend the time once:

@sorted = map { $_->[ 1 ] } sort { $a->[ 0 ] <=> $b->[ 0 ] } map { [ expensivefunc( $_ ), $_ ] } @data;
Doing a naive sort, you would be calling that expensive function twice for every comparison, which would end up being a lot more than when precalculating:
@sorted = sort { expensivefunc( $a ) <=> expensivefunc( $b ) } @data;