1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
4 <TITLE> Schwartian Transform (ST) Sort </TITLE>
6 <H3 ALIGN=CENTER>1.10: Schwartian Transform (ST) Sort </H3>
7 <TABLE ALIGN="CENTER" BORDER=0 WIDTH="95%">
9 <TD WIDTH="25%" ALIGN="LEFT">
10 <A HREF="slide-0109.html">Prev</A>
11 <A HREF="slide-0111.html">Next</A>
12 <A HREF="index.html">Index</A>
15 <TD WIDTH="25%" ALIGN="RIGHT">Page 10/12
20 <li> Caches extracted keys in an anonymous array for each input record
22 <li> Stores the record itself in slot 0 of the array
24 <li> Uses the map/sort/map idiom
26 <li> Popularized by Randal Schwartz
28 <li> Good for medium to large sort sets
30 <li> Key extraction is O( N )
32 <li> Does a full callback to Perl in the comparison block
34 <li> Pass 'ST' option to make_sorter
38 $a->[1] cmp $b->[1]
40 $a->[2] cmp $b->[2]
44 do{ my ($val) = $_->[0] ; $val },
45 do{ my ($val) = $_->[1] ; $val }
51 <TABLE ALIGN="CENTER" BORDER=0 WIDTH="95%">
53 <TD WIDTH="30%" ALIGN="LEFT">
54 <A HREF="slide-0109.html">Prev</A>
55 <A HREF="slide-0111.html">Next</A>
56 <A HREF="index.html">Index</A>
58 YAPC::NA 2004, Buffalo, NY
59 <TD WIDTH="25%" ALIGN="RIGHT">Page 10/12
63 <TD ALIGN="CENTER" COLSPAN="3">
64 <FONT SIZE="-3">© 2004 Uri Guttman</FONT>