Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,30 @@
local function gnome_sort(a, asc)
local size = #a
local i = 2
local j = 3
while i <= size do
if (asc and a[i - 1] <= a[i]) or (!asc and a[i - 1] >= a[i]) then
i = j
j += 1
else
a[i], a[i - 1] = a[i - 1], a[i]
i -= 1
if i == 1 then
i = j
j += 1
end
end
end
end
local array = { {4, 65, 2, -31, 0, 99, 2, 83, 782, 1}, {7, 5, 2, 6, 1, 4, 2, 6, 3} }
for {true, false} as asc do
print($"Sorting in {asc ? "ascending" : "descending"} order:\n")
for array as a do
local b = asc ? a : (a:clone())
print($"Before: \{{b:concat(", ")}}")
gnome_sort(b, asc)
print($"After : \{{b:concat(", ")}}")
print()
end
end