Commit | Line | Data |
7468c584 |
1 | A Fresh Look at Efficient Perl Sorting |
2 | |
3 | Uri Guttman, John Porter, and Larry Rosler |
4 | |
5 | Abstract |
6 | |
7 | Sorting is one of the primary needs of programming, because most |
8 | programs produce reports of sorted data. Efficient sorting therefore |
9 | receives a great deal of attention in the Perl documentation, FAQ, |
10 | FMTYEWTK, books, and newsgroups. In this paper, we review and compare |
11 | several methods for Perl sorting: external ('system'), |
12 | repeatedly-computed-keys ('naive'), cached-keys ('Orcish Maneuver'), and |
13 | mapped-keys ('Schwartz Transform'). We then present a little-known |
14 | approach ('single-string key-and-value'), which relies for efficiency on |
15 | the default sort algorithm. This method typically provides much better |
16 | performance than the other approaches, and is easy to implement directly |
17 | or using a module. |
18 | |
19 | |
20 | |