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 bubble_sort(a)
|
||||
local n = #a
|
||||
if n < 2 then return end
|
||||
repeat
|
||||
local swapped = false
|
||||
for i = 2, n do
|
||||
if a[i-1] > a[i] then
|
||||
a[i], a[i-1] = a[i - 1], a[i]
|
||||
swapped = true
|
||||
end
|
||||
end
|
||||
until !swapped
|
||||
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(", ")}}")
|
||||
bubble_sort(a)
|
||||
print($"After : \{{a:concat(", ")}}")
|
||||
print()
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue