From: Damien WYART Date: 2001-10-09T06:02:37+09:00 Subject: [ruby-talk:22261] Re: [Newbie] Switching from Perl : suffling * Dave Thomas in comp.lang.ruby: > How about something like > class Array > def shuffle > each_index {|i| o = rand(size); self[i], self[o] = self[o], self[i] } > end > end > original = readlines("\n%\n") > puts original.shuffle Wow ! Short and very readable. I'm impressed ! Many thanks. I will check if the shuffle is OK, but for small files, it seems fine. -- Damien