Sorting queries. [was: Melb. PM]

pmartin1 at bigpond.net.au pmartin1 at bigpond.net.au
Wed Jan 9 22:38:23 CST 2002


On 10 Jan 2002, at 12:33, Scott Penrose wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> On Thursday, January 10, 2002, at 12:12 , Jeremy Howard wrote:
> >> You mean there are people out there not using strict :-)
> >> Only kidding. Damian would have lots to say about only using police
> >> if you are in New York, and needing only Mounties if in Canada :-)
> >>
> > Damian scares me--he never uses strict, and it doesn't seem to
> > bother him at all. I don't think I'd be able to produce working code
> > without it, on the other hand. I guess that's why Damian is a Damian
> > and I'm not. ;-)
> 
> Personally I can't see a reason to NOT use strict...
> However, in Damians case, especially modules such as "NEXT" (one of my
> favorite examples of why perl is cool, an extension to the language
> written in native perl) you have to not use strict.
> 
> I have a philosophy that I try and force on our developers where I
> work, which is you can do bad evil things in perl (eg: NEXT) and that
> is fine, but abstract it off into a separate module, both reusable and
> easy to test, code review etc.
> 
> A good example is complex sorts. A neat feature (see use.perl.org) a
> while ago suggested that the fastest way to do a sort on multiple
> fields is to use pack and then the built in sort without an anonymous
> sub. By not passing a sub you are using the built in fast C sort
> method. Very cool, one of our developers used that to produce a
> massive increase in the performance of a mail system. However the code
> looks confusing and nasty, so it is best to either put it in a class
> method somewhere or make the array an object and a new method on that.
> eg:
>  foreach my $bit ($ref->sort)
> or
>  foreach my $bit (MyFastSort::sort(@somearray))
> 
When the first draft of the paper showing that sort method was
published, there was a suggestion the authors were throwing
together a module to handle this kind of sorting. 

Anyone seen/heard what happened with that proposed module ?

Meanwhile, I seem to recall the (revised) inbuilt sort in Perl
was a quicksort with a median-of-three partitioning method
for elements, and a subroutine for partly-sorted partitions that
switched to insertion or bubble sort .

I thought I could recognise the C code for this when I saw it, but
looking at the Perl source only made my head hurt.

Anyone recall the algorithms applied ?




More information about the Melbourne-pm mailing list