Module:Sandbox/Hilycker/SortTest
Documentation for this module may be created at Module:Sandbox/Hilycker/SortTest/doc
local p = {}
local somedata = mw.loadData [[Module:Sandbox/Hilycker/SortTest/data]]
local Table = require('Module:Table')
function p.sortTest()
table.sort(somedata)
return somedata
end
function p.makeTable()
local sorted = p.sortTest()
-- this table of styles corresponds to each of the columns
local tbl = mw.html.create('table'):addClass('wikitable') -- create a wikitable html class
tbl:tag('tr') -- and make its header row
:tag('th'):wikitext('Key'):done()
:tag('th'):wikitext('Value'):done()
for _, row in pairs(sorted) do -- now iterate over the formatted data
for k, v in pairs(row) do
tr = tbl:tag('tr') -- create a row
-- create each of the columns within the row,
-- with the style we defined above and the wikitext as the row value we made in the earlier function
tr:tag('td'):wikitext(k)
tr:tag('td'):wikitext(v)
end
end
return tbl -- done!
end
return p