local getArgs = require('Module:Arguments').getArgs
local p =
function p._encode(sortkey) -- Protect against sortkey nesting. -- Example: if string.find(sortkey, "sortkey") or string.find(sortkey, "data-sort-value") then return ""; end return mw.text.encode(sortkey)end
function p.encode(frame) local args = getArgs(frame); return p._encode(args[1] or "")end
local function valid_number(num) -- Return true if num is a valid number. -- In Scribunto (different from some standard Lua), when expressed as a string, -- overflow or other problems are indicated with text like "inf" or "nan" -- which are regarded as invalid here (each contains "n"). if type(num)
nil then return true endend
function p._sortKeyForNumber(value) local sortkey if not valid_number(value) then if value < 0 then sortkey = '1000000000000000000' else sortkey = '9000000000000000000' end elseif value
function p.sortKeyForNumber(frame) local args = getArgs(frame); return p._sortKeyForNumber(args[1] or "")end
return p