[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] sorting arrays



On Thu, 17 Jun 1999, Richard K. Moore wrote:

> 6/16/99, Ronald J Kimball wrote:
>  >If you want to sort the entire file by line, you have to read the entire
>  >file into memory.  You can then use a Schwartzian Transform to efficiently
>  >sort the lines:
> 
> I'm curious as to why people haven't been advising the use of a hash (or
> two).  Alan's application seems to be one with only a small amount of data.
> Is the Schwartzian Transform incredibly faster as a solution for large
> amounts of data?
> 
It's a pretty standard way to go these days, and it won't let you down.

If you're willing to tweak you can usually come up with somewhat faster
sorts for particular problems. I benchmarked the provided S.T. over 1000
iterations with the problem data vs. 1000 iterations of a sorting solution
that used sprintf() to line the first name and surname up in a single
string, and sorted _that_, and the latter was about 25% faster. But I lost
the speed gain in recreating the original format for printout, so...

Normally I'd just use the S.T. myself.

Arved



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org