Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,19 @@
|
|||
local function insertion_sort(a)
|
||||
for i = 2, #a do
|
||||
local v = a[i]
|
||||
local j = i - 1
|
||||
while j >= 1 and a[j] > v do
|
||||
a[j + 1] = a[j]
|
||||
j -= 1
|
||||
end
|
||||
a[j + 1] = v
|
||||
end
|
||||
end
|
||||
|
||||
local array = { {4, 65, 2, -31, 0, 99, 2, 83, 782, 1}, {7, 5, 2, 6, 1, 4, 2, 6, 3} }
|
||||
for array as a do
|
||||
print($"Before: \{{a:concat(", ")}}")
|
||||
insertion_sort(a)
|
||||
print($"After : \{{a:concat(", ")}}")
|
||||
print()
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue