| Learn | Perl - Sorting - The schwartzian transform |
|---|
| The Schwartzian Transform This is probably the most famous example of a sort optimization making use of Perl's functional programming facilities, to be used where the sort order of items depend on an expensive function. The trouble with the first example is that the comparator is called very often and keeps recalculating values using a slow function over and over. A typical example would be sorting file names by their file size: This works, but at best it incurs the overhead of two system calls per comparison, at worst it has to go to the disk, twice, for every single comparison, and that disk may be in an overloaded file server on the other side of the planet. Enter Randall Schwartz's trick. The Schwartzian Transform basically shoves |
Read Article
https://develop.horje.com/learn/1434/reference