ID:159275
 
How can I get list as a type of input to a proc?
world/proc/rearrange(input as list)

Bad input type.

What I'm trying to achieve is basically the php equivalent of..

$bob = rearrange($bob);

function rearrange($input)
{
// Rearranging stuff here
return $input
}
I don't know exactly what you mean by your post but I think you mean something along these lines...

proc/rearrange()
var/x = input("","") as null|anything in list //where 'list' is whatever list var you're using
if(x)
//...
In response to Spunky_Girl
Not quite. I'm not after seeking input from the user. I have all the input I just want to re-arrange the list.
In response to Bunnie
Then you'll want to look up the Cut() Swap() and Copy() list pocs
I think that, what you're looking for is proc_name(var/list/list_name), or proc_name(list_name[]).

Just as a senseless stupid example:

mob
verb
Test()
var/list/Li = list(1, 2, 3)
var/list/Lr = l_t(Li)
for(var/p in Lr)
world << "[p]"


proc
l_t(L[])
if(L.len)
for(var/i = 1, i <= L.len, i++)
L[i] += i
return L
The as clause designates a type of input when used as a verb argument. When passing proc arguments, you typecast:

proc/sort(list/l)
is(istype(l)) world << l.len

//alternatively, something like
proc/sort(a)
var/list/l = a
world << l.len


As for sorting the list, what you're after is called bubble sorting.