import random
import numpy as np
import numpy.random
a = np.array([1,2,3,4,5,6])
a.shape = (3,2)
print a
random.shuffle(a) # a will definitely be destroyed
print a
# arr = numpy array to shuffle
def shuffle(arr):
a = numpy.arange(len(arr))
b = numpy.empty(1)
for i in range(len(arr)):
sel = numpy.random.random_integers(0, high=len(a)-1, size=1)
b = numpy.append(b, a[sel])
a = numpy.delete(a, sel)
b = b[1:].astype(int)
return arr[b]