Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 29th, 2010  |  syntax: Python  |  size: 0.32 KB  |  views: 100  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # proof of concept only -
  2. # this functionality already available from random.shuffle()
  3. import random
  4. def shuffle(arr):
  5.     array_length = len(arr)
  6.     for index in xrange(array_length):
  7.         random_index = random.randint(index, array_length-1)
  8.         arr[index], arr[random_index] = arr[random_index], arr[index]