From: Robert Dober Date: 2007-02-26T19:16:12+09:00 Subject: Re: extract a random number of items from an array Ooops bad formatting again, sorry for the repost folks: On 2/26/07, Robert Dober wrote: > Actually James' solution does not give you n elements, maybe you want to try this an_ary.sort_by{ rand }[0..n-1] # Might use a second or two of CPU for millions of elements though ;) should do the trick unless you want a *stable* subarray. Stable means that if x occurs on the LHS of y in an_ary it also does in your subarray, but if I read you correctly you did not need this. Cheers Robert