| Start |
|---|
Basic Lexical Sort The three examples above do exactly the same thing. If you don't supply any comparator function or block,
If you |
| 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 |
| Case Insensitive Sort The traditional technique to make This works on all versions of Perl 5 and is completely sufficient for English; it doesn't matter whether you use |
Numeric Sort Comparing |
Reverse Sort Sorting items in descending order can simply be achieved by swapping Syntax
|
Read Article
https://develop.horje.com/learn/1434/reference