SHARE
TWEET

Untitled

a guest Jul 29th, 2010 118 Never
  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]
RAW Paste Data
Top