Module:Sandbox/Nyoron/anyToString explained

local p =

local T = local T_table =

local function table_sort_f(a,b) if type(a)

'nil' then return true end

if type(a)

'boolean' then if type(b)

'nil' then return false end if type(b)

'boolean' then return tostring(a) < tostring(b) end return true end

if type(a)

'number' then if type(b)

'nil' then return false end if type(b)

'boolean' then return false end if type(b)

'number' then return a < b end return true end

if type(a)

'string' then if type(b)

'nil' then return false end if type(b)

'boolean' then return false end if type(b)

'number' then return false end if type(b)

'string' then return a < b end return true end

if type(a)

'function' then if type(b)

'nil' then return false end if type(b)

'boolean' then return false end if type(b)

'number' then return false end if type(b)

'string' then return false end if type(b)

'function' then return T.func.name[a] < T.func.name[b] end return true end

if type(a)

'table' then if type(b)

'nil' then return false end if type(b)

'boolean' then return false end if type(b)

'number' then return false end if type(b)

'string' then return false end if type(b)

'function' then return false end if type(b)

'table' then return T_table.name[a] < T_table.name[b] end return true end

return trueend

local function __anyToString(var, indent, indent2)

local tp = type(var) if tp

'table' then if T_table.name[var]

nil then T_table.num = T_table.num + 1 T_table.name[var] = 'table_' .. tostring(T_table.num) end if T_table.done[var] then return T_table.name[var] end T_table.done[var] = true local sb = if not T_table.started then T_table.started = true sb = sb[#sb + 1] = T_table.name[var] .. ' =