Re: sorting by rand?
- From: seebs@xxxxxxxxx (Peter Seebach)
- Date: Mon, 30 Apr 2007 16:46:44 +0900
In message <4635AB25.9050809@xxxxxxxxx>, 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
.
- Follow-Ups:
- Re: sorting by rand?
- From: Dan Zwell
- Re: sorting by rand?
- References:
- Re: sorting by rand?
- From: Dan Zwell
- Re: sorting by rand?
- Prev by Date: Re: sorting by rand?
- Next by Date: Re: sorting by rand?
- Previous by thread: Re: sorting by rand?
- Next by thread: Re: sorting by rand?
- Index(es):