On 5/14/05 Leif Andersson wrote: >It is funny, I started with a Schwartzian transform, but thought to >myself "why not simplify the code?". Not realizing it is a performance >gain. I have always thought of it only as a means to do more >complicated sorts. >... >Funny, once more, is that one member of this list contacted me >off-list asking if it is possible to sort only _some_ of the fields in >a pre-defined order. It is possible. We could assing a sort key to >those fields. And make use of the Schwartzian Transform!
If you haven't seen it, you might be interested in the "packed-default" sort described by Uri Guttman and Larry Rosler, and now usually refered to as the Guttman-Rosler sort. For their original paper, see: <http://www.sysarch.com/perl/sort_paper.html> Packed-default allows arbitrarily complex multi-field sorts to use the fast native sort function. In data analysis tools I've written, the packing pattern for the sort key is generated from meta-data, so I don't even have to think about optimal packing patterns for various types of data. Sometimes it's also handy to store the list of packed sort keys after the sort, as a kind of quickie uniform index of the selected data. Some searching on "Guttman-Rosler" would yield interesting follow-up discussion... Have fun, - Bruce __bruce__van_allen__santa_cruz__ca__