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
from random import random my_list = range(10) shuffled_list = sorted(my_list, key=lambda x: random())
This alternative may be useful for some applications where you want to swap the ordering function.