What code can I use if I have ten numbers and I want to produce 1000 different randomly shuffled orders of the the ten numbers
<p>I can use this to find all of the possible options, however, I want a random sample of 1000 from this set:</p>

<pre><code>items = range(1,11)
//from itertools import permutations
//for p in permutations(items):
print(p)
</code></pre>

<p>Unfortunately, Python's permutation module only provides a way to iterate through the 3-million-plus permutations, and not a way to pick one arbitrarily by order.  You'll need something like this:</p>

<pre><code>def kthperm(S, k):
    P = []
    while S != []:
        f = math.factorial(len(S)-1)
        i = int(math.floor(k/f))
        x = S[i]
        k = k%f
        P.append(x)
        S = S[:i] + S[i+1:]
    return P
</code></pre>

<p>Now you can pick a random number from 0 to 10!-1, compute that permutation directly, and add it to your list, as many times as needed:</p>

<pre><code>perms = []
for i in range(1000):
    perms.append(kthperm(list(range(1,11)),
      random.randint(0,math.factorial(10)-1))
</code></pre>

python random permutation shuffle sample