Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,21 @@
|
|||
local function selection_sort(a)
|
||||
for i = 1, #a- 1 do
|
||||
local amin = a[i]
|
||||
local imin = i
|
||||
for j = i + 1, #a do
|
||||
if a[j] < amin then
|
||||
amin = a[j]
|
||||
imin = j
|
||||
end
|
||||
end
|
||||
a[i], a[imin] = amin, a[i]
|
||||
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(", ")}}")
|
||||
selection_sort(a)
|
||||
print($"After : \{{a:concat(", ")}}")
|
||||
print()
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue