模块:SortArgs:修订间差异
跳到导航
跳到搜索
Willson-v-(讨论 | 贡献) (建立内容为“local module = {} function module.sortedArgs(args, sort_ref, ref_sep) local args_dump = {} sort_ref = mw.text.split(sort_ref, ref_sep, false) if #sort_ref the…”的新页面) |
(没有差异)
|
2022年5月4日 (三) 12:36的最新版本
此模块的文档可以在模块:SortArgs/doc创建
local module = {} function module.sortedArgs(args, sort_ref, ref_sep) local args_dump = {} sort_ref = mw.text.split(sort_ref, ref_sep, false) if #sort_ref then table.remove(sort_ref, #sort_ref) end for idx, key in ipairs(sort_ref) do args_dump[idx] = { key, args[key] or args[tonumber(key)] } end local index = 0 return function () index = index + 1 if not args_dump[index] then index = 0 return nil end return unpack(args_dump[index]) end end return module