Added lovebird.compare() for improved sorting in env browser

This commit is contained in:
rxi 2014-04-18 13:01:36 +01:00
parent 943c0c48df
commit 1e4eb39820

View File

@ -346,7 +346,7 @@ lovebird.pages["env.json"] = [[
table.insert(keys, k)
end
end
table.sort(keys, function(a, b) return tostring(a) < tostring(b) end)
table.sort(keys, lovebird.compare)
for _, k in pairs(keys) do
local v = t[k]
?>
@ -447,6 +447,18 @@ function lovebird.truncate(str, len)
end
function lovebird.compare(a, b)
local na, nb = tonumber(a), tonumber(b)
if na then
if nb then return na < nb end
return false
elseif nb then
return true
end
return tostring(a) < tostring(b)
end
function lovebird.checkwhitelist(addr)
if lovebird.whitelist == nil then return true end
for _, a in pairs(lovebird.whitelist) do