Files
Citadel-Station-13-RP/code/__HELPERS/lists/shuffle.dm
Zandario ed05e01a95 __HELPERS Cleaning and other things I decided to do. (#4584)
* Schizoposting

* The Crungly

* Tabbin' the JSON y'all

* Strings
2022-10-21 01:56:59 -07:00

24 lines
309 B
Plaintext

/**
*
*/
/proc/shuffle(list/L)
if(!L)
return
L = L.Copy()
for(var/i=1; i<L.len; i++)
L.Swap(i, rand(i,L.len))
return L
/**
* Randomize: Returns nothing and acts on list in place.
*/
/proc/shuffle_inplace(list/L)
if(!L)
return
for(var/i=1, i<L.len, ++i)
L.Swap(i,rand(i,L.len))
return L