Модул:Sorted plain list — разлика између измена
Пређи на навигацију
Пређи на претрагу
(+) |
м (1 измена увезена) |
||
| (Нису приказане 2 међуизмене 2 корисника) | |||
| Ред 4: | Ред 4: | ||
local lang = mw.getContentLanguage() | local lang = mw.getContentLanguage() | ||
function p.asc(frame) | function p.asc(frame) | ||
items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true) | |||
if (frame.args['type'] or '') == 'number' then | if (frame.args['type'] or '') == 'number' then | ||
table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) < (lang:parseFormattedNumber(b) or math.huge)) end ) | table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) < (lang:parseFormattedNumber(b) or math.huge)) end ) | ||
| Ред 53: | Ред 16: | ||
function p.desc(frame) | function p.desc(frame) | ||
items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true) | |||
if (frame.args['type'] or '') == 'number' then | if (frame.args['type'] or '') == 'number' then | ||
table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) > (lang:parseFormattedNumber(b) or math.huge)) end ) | table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) > (lang:parseFormattedNumber(b) or math.huge)) end ) | ||
else | else | ||
table.sort( items, function (a, b) return a > b end ) | table.sort( items, function (a, b) return a > b end ) | ||
end | end | ||
return '<div class="plainlist"><ul><li>' .. table.concat( items, "</li><li>" ) .. '</li></ul></div>' | return '<div class="plainlist"><ul><li>' .. table.concat( items, "</li><li>" ) .. '</li></ul></div>' | ||
Тренутна верзија на датум 5. фебруар 2021. у 13:51
Документацију овог модула можете да направите на страници Модул:Sorted plain list/док
-- This module generates a sorted plain list
-- It was created as a modification of [[Module:Sort]]
local p = {}
local lang = mw.getContentLanguage()
function p.asc(frame)
items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true)
if (frame.args['type'] or '') == 'number' then
table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) < (lang:parseFormattedNumber(b) or math.huge)) end )
else
table.sort( items )
end
return '<div class="plainlist"><ul><li>' .. table.concat( items, "</li><li>" ) .. '</li></ul></div>'
end
function p.desc(frame)
items = mw.text.split( frame.args[1] or '', frame.args[2] or ',', true)
if (frame.args['type'] or '') == 'number' then
table.sort( items, function (a, b) return ((lang:parseFormattedNumber(a) or math.huge) > (lang:parseFormattedNumber(b) or math.huge)) end )
else
table.sort( items, function (a, b) return a > b end )
end
return '<div class="plainlist"><ul><li>' .. table.concat( items, "</li><li>" ) .. '</li></ul></div>'
end
return p