seebs
4/30/2007 7:47:00 AM
In message <4635AB25.9050809@gmail.com>, Dan Zwell writes:
>You're right. I guess I'm just inclined to discount a such a small
>difference in orderings. And the difference in our benchmarks may have
>been due to the fact that I'm using a different algorithm (for each
>element i, swap i with an element from i...end).
Hmm. I don't *think* that makes a difference, although I'm not sure.
It may affect the results.
>Or perhaps because I
>have more method calls, as I made a method Array#randomize! (that calls
>Array#swap! n times)
That might well do it; method lookup is comparatively expensive, I
think.
... Of course, the entire thing is probably silly, in that I doubt most
programs spend much time unsorting arrays. I was mostly just curious
about the question of what happens if you try to provide an un-fixed
sort key. For sort_by, they're cached; sort { rand <=> rand } might
be unpredictable, though.
-s