Write a simple logic to shuffle a given array.
Consider this array -
|
|
You can shuffle this array by using the following code -
|
|
Each run of the routine will give you a different array, thanks to Math.random() expression. Subtracting one random number from the other can give you a positive or negative result - so the sort can be totally different and random.
However, the arrays may not be unique. It is highly likely that you encounter duplicates when shifting through a larger number of possible permutations of the array.