Help


from Wikipedia
« »  
There are other, less-desirable algorithms in common use.
For example, one can assign a random number to each card, and then sort the cards in order of their random numbers.
This will generate a random permutation, unless any of the random numbers generated are the same as any others ( i. e. pairs, triplets etc .).
This can be eliminated either by adjusting one of the pair's values randomly up or down by a small amount, or reduced to an arbitrarily low probability by choosing a sufficiently wide range of random number choices.
If using efficient sorting such as mergesort or heapsort this is an O ( n log n ) average and worst-case algorithm.

2.257 seconds.