Kontent qismiga oʻtish

Modul:Sort list

ZiyoSfera, erkin ensiklopediya
2026-yil 25-sentyabr, 21:49 dagi Admin (munozara | hissa) versiyasi
(farq) ←Avvalgi koʻrinishi | Hozirgi koʻrinishi (farq) | Yangiroq koʻrinishi→ (farq)

Bu modul uchun Modul:Sort list/doc nomli hujjat sahifasini yaratishingiz mumkin

require[[strict]]
local p = {}

local function splitLine( text )
    return mw.text.split( text, "\n", true );    
end

function p.asc(frame)
    local items = splitLine( frame.args[1] );
    table.sort( items );
    return table.concat( items, "\n" );    
end

function p.desc(frame)
    local items = splitLine( frame.args[1] );
    table.sort( items, function (a, b) return a > b end );
    return table.concat( items, "\n" );
end

return p