mob/verb/Test()
var/list/nums = list(2,10,4,55)
nums = BubbleSort(nums)
world << list2text(nums)
proc/BubbleSort(var/list/L)
var/remain = L.len + 1
while(remain)
remain --
if(L[1] < L[2])
L.Swap(1,2)
if(L[2] < L[3])
L.Swap(2,3)
if(L[3] < L[4])
L.Swap(3,4)
sleep(0.1)
return L
Using the Test() verb, I get the output(through list2text()) "55, 10, 4, 2". But if I were to make nums "2,44,1,66,46,77,22,99" I get the output "66, 44, 2, 1, 46, 77, 22, 99". This is because in BubbleSort(), I'm only swapping up to 4 things.
How can I swap n number of things?