29 lines
551 B
Lua
29 lines
551 B
Lua
aux 'sorting'
|
|
|
|
public.EQ = 0
|
|
public.LT = 1
|
|
public.GT = 2
|
|
|
|
function public.compare(a, b, desc)
|
|
if a < b then
|
|
return desc and GT or LT
|
|
elseif a > b then
|
|
return desc and LT or GT
|
|
else
|
|
return EQ
|
|
end
|
|
end
|
|
|
|
function public.multi_lt(xs, ys)
|
|
local i = 1
|
|
while true do
|
|
if xs[i] and ys[i] and xs[i] ~= ys[i] then
|
|
return xs[i] < ys[i]
|
|
elseif not xs[i] and ys[i] then
|
|
return true
|
|
elseif not ys[i] then
|
|
return false
|
|
end
|
|
i = i + 1
|
|
end
|
|
end |