Advertisement
Yarukinasu

listshuffle

Jul 27th, 2011
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. listshuffle = [
  2.   _tmplist = $arg1
  3.   bloop i (listlen $arg1) [
  4.     if (> $i 1) [
  5.       _tmpindex = (- $i 1)
  6.       _tmpitem = (at $_tmplist $_tmpindex)
  7.       _rndindex = (rnd $i)
  8.       _rnditem = (at $_tmplist $_rndindex)
  9.       _tmplist = (listreplace $_tmplist $_rndindex $_tmpitem)
  10.       _tmplist = (listreplace $_tmplist $_tmpindex $_rnditem)
  11.     ]
  12.   ]
  13.   result $_tmplist
  14. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement