Shuffle(var/list/L)
var/iters = 4 * L.len
/* The number of iterations isn't terribly important, as long as it's sufficiently large.
For larger data sets, you will need larger iterations. */
var/i1 = 0 // index to swap
var/i2 = 0 // index to swap
while(iters)
i1 = rand(1, L.len)
i2 = rand(1, L.len)
L.Swap(i1, i2) // swaps indexes
iters -- // loop counter down.
Note: I store these sorts of procs as global procs, this is easily moved into a mob.Shuffle() proc or something.
What you should make is a realistic shuffling proc if you're dealing with cards. If I remember correctly my grandmother would shuffle five times before each hand with a cut between each shuffle. Assume shuffling interlaces cards from the top half of the cards and the bottom half of the cards and that cuts always happen right down the middle and swap the top and bottom halves of the deck.
Make it by only doing procedures on the list passed in, you can assume that there will always be an even number of elements.