mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-10 18:08:13 -06:00
merged gui
This commit is contained in:
@@ -49,3 +49,46 @@ end
|
||||
function irpairs(a)
|
||||
return irnext, a, 0
|
||||
end
|
||||
|
||||
---@generic V
|
||||
---@param arr Array<V>
|
||||
---@param comp fun(a: V, b: V) A comparison function for sorting. Must return truthy if `a < b`.
|
||||
function stable_sort(arr, comp)
|
||||
local size = #arr
|
||||
for i = 2, size do
|
||||
local a = arr[i]
|
||||
local j = i
|
||||
while j > 1 do
|
||||
local b = arr[j - 1]
|
||||
if comp(a, b) then
|
||||
arr[j] = b
|
||||
j = j - 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
arr[j] = a
|
||||
end
|
||||
end
|
||||
|
||||
---@param values number[]
|
||||
---@param keys any[]
|
||||
function dual_sort(values, keys)
|
||||
local size = #values
|
||||
for i = 2, size do
|
||||
local a = values[i]
|
||||
local j = i
|
||||
while j > 1 do
|
||||
local b = values[j - 1]
|
||||
if a < b then
|
||||
values[j] = b
|
||||
keys[j] = keys[j - 1]
|
||||
j = j - 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
values[j] = a
|
||||
keys[j] = keys[i]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user