ID:260155
 
This command will shuffle all items in said list in a random order.
You can use this for now.
proc/list_shuffle(list/L)
var/list/temp = L.Cut()
var/element
var/n = temp.len
for(var/index = 1 to n)
element = pick(temp)
L[element] = temp[element] //preserves assosiated values
temp.Remove(element)

I am assuming list/Cut asserves assosiated values as well. If it doesn't, then trying to do so where I did won't accomplish anything.

That should shuffle the list, and it should allow you to keep the same list object too so that it is properly preserved for anything that references it.
In response to Loduwijk
Don't you mean L.Copy()?
In response to Papoose
No, I mean L.Cut. I want to empty L at the same time so that I can re-add the elements in random order. If I did L.Copy, I would end up with L having all its elements twice - once in the original order then another time in scrambled order after that.

I did make a typo though. L.len should be temp.len, and I just fixed that.
In response to Loduwijk
Ah, I see. I didn't recognize the method at first, I usually do it as stated in the post [link].
In response to Loduwijk
The code you posted will only work properly on lists with unique values. Shuffling is much easier to accomplish via Swap().

Lummox JR
Android Data wrote:
This command will shuffle all items in said list in a random order.

It'd be utterly useless to implement this internally when anyone can write a quicky shuffle proc.
proc/Shuffle(list/L)
for(var/i=L.len, i>1, --i) // >1 is intentional, not >0 or >=1
j = rand(1, i)
if(i > j) L.Swap(i, j)

Lummox JR
In response to Lummox JR
I don't agree with you that it is useless to implement this internally. Although it is easiely added in, a shuffle proc would just add even more things that can be done automaticly. Perhaps it should be low on the priority listings, but it is so simple that it would take almost no effort to add into DM, then it would just be a matter of updating the reference.
In response to Scoobert
Something that could be a little useful to newcomers is a list that could be in the reference that shows how to program simple procs such as this. After a while the newcomer would know how to edit it, and it would take less time to write this up in the reference than add it internally.
In response to Popisfizzy
Perhaps a special library could be made with some cool functions that people found to be useful?
In response to Scoobert
Scoobert wrote:
I don't agree with you that it is useless to implement this internally. Although it is easiely added in, a shuffle proc would just add even more things that can be done automaticly. Perhaps it should be low on the priority listings, but it is so simple that it would take almost no effort to add into DM, then it would just be a matter of updating the reference.

Just because something is widely useful does not mean it should be implemented as a language feature. Speedwise there'd be no point, since a user-defined proc does just as well. list.Swap() and list.Insert() were vitally needed because replicating their functions was far more difficult, yet they both have major utility. A shuffle proc would have no such advantages.

Instead, a shuffle proc sounds like a good candidate for a pamphlet. Those are my own idea for microlibraries that can get bundled together. Currently no pamphlet support exists, but I believe Tom found the concept intriguing so maybe at some point there will be.

Lummox JR
In response to Android Data
Android Data wrote:
Perhaps a special library could be made with some cool functions that people found to be useful?

Like http://developer.byond.com/hub/Kunark/KunarkLib ?

There's a few libraries by people which have a bunch of functions they commonly use. I belive ShadowDarke has one somewhere, too.