From: Lionel Bouton Date: 2007-08-27T06:58:41+09:00 Subject: Re: sort_by { rand } not working Dan Zwell wrote: > > for i in 0...@all.length > j = i+rand(@all.length-i) > @all[i], @all[j] = @all[j], @all[i] > end > > The second one will be faster, but you probably shouldn't care on > small arrays. > You could even optimize this further with 0...@all.length-1 instead of 0...@all.length (the last loop is a noop), but I agree, this is too much pain for the eyes to bother unless it becomes a real performance problem. Sorry if this has already been said, in fact I didn't even remember this code on the mailing-list at all (too much traffic for me maybe). Lionel