local function bubblesort(array)
for getal = 1, #array do
for i = 1, #array do
print('i = '..tostring(i)..', array[i] = '..tostring(array[i]))
print('i+1 = '..tostring(i+1)..', array[i+1] = '..tostring(array[i+1]))
if array[i] > array[i + 1] then
local temp = array[i]
array[i + 1] = array[i]
array[i + 1] = temp
end
end
end
return array
end
local arr = { 2, 5, 1 }
local sorted = bubblesort(arr)
To embed this project on your website, copy the following code and paste it into your website's HTML: