Files
aux-addon-ClassicAPI/util/sort.lua
T
Manuel Simon Hirsig 71adb9c916 big refactoring
2016-08-22 08:00:33 +02:00

29 lines
557 B
Lua

module 'sorting'
public.LT = {}
public.EQ = {}
public.GT = {}
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