SyntaxFix
Write A Post
Hire A Developer
Questions
You can sort your array with random key
sorted(array, key = lambda x: random.random())
key only be read once so comparing item during sort still efficient.
but look like random.shuffle(array) will be faster since it written in C
random.shuffle(array)