Jump to content

Module:Sort list

ពីវិគីភីឌា
កំណែ​នៅ ម៉ោង០៣:១១ ថ្ងៃពុធ ទី២៦ ខែសីហា ឆ្នាំ២០២០ ដោយ RalvahKaset (ការពិភាក្សា | ការរួមចំណែក) (បានបង្កើតទំព័រដែលផ្ដើមដោយ local p = {} function p.asc(frame) items = splitLine( frame.args[1] ); table.sort( items ); return table.c...)
(ប្រៀបធៀប) ← កំណែ​ចាស់ជាង | កំណែថ្មីបំផុត (ប្រៀបធៀប) | កំណែថ្មីជាង → (ប្រៀបធៀប)

Documentation for this module may be created at Module:Sort list/doc

local p = {}

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

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

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



return p