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

Re: [FWP] Wanted - Have = Need



2000-10-17-13:38:38 Josh L Rabinowitz:
> Seems to me that if the comparison function is non-deterministic
> then qsort is bound to barf (or at best, sort non-sensically).

Well, I was pretty sure I remembered hearing some chatter about
perl's sort blowing cores if a bad comparison function was used (one
that returned different results on different calls with the same
parameters), but I hadn't recalled the bit about perl getting its
own robust sort to deal with this. So I just tried

	perl -le 'print sort { rand() <=> 0.5 } 0..9'

a few times, and it seems like a shuffler under
5.005_03. A very perverted shuffler. For some reason, this reminds
me of the sort algorithm, where you repeatedly shuffle the inputs,
checking to see if they happened to land in sorted order after each
shuffle.

-Bennett

PGP signature