Generates a random permutation