Add new code snippets

This commit is contained in:
2024-03-03 13:50:12 +01:00
commit 01b612a50b
409 changed files with 65292 additions and 0 deletions

19
Sort Array.lua Normal file
View File

@@ -0,0 +1,19 @@
local array = {13, 14, 52, 63, 764, 12342, 143, 2, 54, 63, 25, 15}
local sortedarray = {0}
for ka, va in ipairs(array) do
for j = 1, #sortedarray do
if va > sortedarray[j] then
if sortedarray[j] > 0 then
for i = #sortedarray, j, -1 do
sortedarray[i + 1] = sortedarray[i]
end
end
sortedarray[j] = va
end
end
end
for k, v in ipairs(sortedarray) do
print(k, v)
end