From: Patrick Hurley Date: 2006-09-07T07:24:47+09:00 Subject: Re: NArray shuffle On 9/6/06, Daniel Martin wrote: > "Patrick Hurley" writes: > > > Has anyone ever needed to "shuffle" an NArray? I can certainly convert > > it to an array and do the sort_by {rand} idiom, and then convert it > > back. I currently: > > What about: > > shuffled = orig[NArray.float(*orig.shape).random!.sort_index] > > -- > s=%q( Daniel Martin -- martin@snowplow.org > puts "s=%q(#{s})",s.map{|i|i}[1] ) > puts "s=%q(#{s})",s.map{|i|i}[1] > > Thanks Daniel, that is perfect -- I did not know you could index an NA with an Array that way -- its perfect for my needs (plus it keeps the type of the Array). pth