I have a list of objects and I want to shuffle them. I thought I could use the random.shuffle method, but this seems to fail when the list is of objects. Is the
random.shuffle
One can define a function called shuffled (in the same sense of sort vs sorted)
shuffled
sort
sorted
def shuffled(x): import random y = x[:] random.shuffle(y) return y x = shuffled([1, 2, 3, 4]) print x