Module:Sandbox/Danski454/UBLSortable
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local TableTools = require('Module:TableTools')
local ListModule = require('Module:List')
-- based on [[Module:Sort list]]
function p.asc(frame)
local args = getArgs(frame)
return p._asc(args)
end
function p._asc(args)
local listItems = {}
-- loop over args (copied from [[Module:Old XfD multi]])
for k, v in pairs(args) do
if type(k) == 'string' then
local prefix, num = k:match('^(.-)([1-9][0-9]*)$')
if prefix and num then
num = tonumber(num)
if not listItems[num] then listItems[num] = {} end
listItems[num][prefix] = v
end
end
end
listItems = TableTools.compressSparseArray(listItems)
table.sort(listItems, function (a, b)
local ak = a.key or a.item
local bk = b.key or b.item
if tonumber(ak) and tonumber(bk) then
return tonumber(ak) < tonumber(bk)
else
return ak < bk
end
end)
return p.renderList(listItems)
end
function p.desc(frame)
local args = getArgs(frame)
return p._desc(args)
end
function p._desc(args)
end
function p.renderList(listItems)
local args = {}
for i=1, #listItems do
if listItems[i].item and mw.ustring.find(listItems[i].item, '%S') then
args[#args+1] = listItems[i].item
end
end
return ListModule.makeList('unbulleted', args)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.