Rick Denatale wrote: > class Array > def shuffle! > i = length - 1 > while (i > 0) > j = rand(i) > # Swap self[i] and self[j] > # This might be more elegant using a parallel assignment, but > # parallel assignment generates a temporary array, so this is > # a little closer to the C code > tmp = self[i] > self[i] = self[j] > self[j] = tmp > i -= 1 > end > self > end > So shuffle is O(n) whereas any sort is going to be O(>n) I'm still on 1.8.6, which doesn't have shuffle, but i'll use this algorithm in my own randomize method, it's nice. Eric, thanks for the suggestion about unseeding rand before returning, good idea. Thanks again, guys, great stuff. -- Posted via http://www.ruby-forum.com/.