mirror of
https://github.com/rxi/lovebird.git
synced 2024-12-09 01:04:22 +00:00
Added lovebird.compare() for improved sorting in env browser
This commit is contained in:
parent
943c0c48df
commit
1e4eb39820
14
lovebird.lua
14
lovebird.lua
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user