local p = ;
function p.sort(frame) --local wikitable = frame.args[1] local wikitable = '! data-sort-type="alpha; first: ascending; initial: 30;" Countries\n! data-sort-type="number; first: descending; initial: 1;" Population\n! data-sort-type="date; first: ascending; initial: 2;" Date' local rows = mw.text.split(wikitable, '\n') local rowstosort = for _, row in ipairs(rows) do mw.log(tostring(row)) local indexStart = string.find(row, 'initial: %d')-- mw.logObject(indexStart) local fromStart = string.sub(row, indexStart + 9)-- mw.logObject(fromStart) local indexEnd = string.find(fromStart, '[^0-9]', 1)-- mw.logObject(indexEnd) local sortValue = string.gsub(string.sub(fromStart, 0, indexEnd), ';', ) mw.log(sortValue) rowstosort[sortValue ] = row end mw.logObject(rows) mw.logObject(rowstosort) return rowsend
return p