Randomize an array in javascript and in Python Randomizing arrays To randomize an array in javascript there is this way: a = [1,2,3,4,5] a.sort(function() {return .5 - Math.random()}); In Python you can you shuffle from the random module from random import shuffle a = [1,2,3,4,5] shuffle(a)