demo_ref_random_shuffle2.py:
import random def myfunction(): return 0.1 mylist = ["apple", "banana", "cherry"] random.shuffle(mylist, myfunction) print(mylist)
➜ begtut>python demo_random_shuffle2.py
["banana", "cherry", "apple"]