-- For testing, show results using data from [[Module:Team appearances list/data]].localCollection={}Collection.__index=CollectiondofunctionCollection:add(item)ifitem~=nilthenself.n=self.n+1self[self.n]=itemendendfunctionCollection:join(sep)returntable.concat(self,sep)endfunctionCollection:sort(comp)table.sort(self,comp)endfunctionCollection.new()returnsetmetatable({n=0},Collection)endendlocalfunctionget_page_content(page_title)localt=mw.title.new(page_title)iftthenlocalcontent=t:getContent()ifcontentthenifcontent:sub(-1)~='\n'thencontent=content..'\n'endreturncontentendenderror('Could not read wikitext from "[['..page_title..']]".',0)endlocalfunctionmake_data(modname)-- Return a list of tables for each competition/team in the order used in-- the data module, based on a hope that the data module is consistently-- indented with one tab before competitions and two or more before teams,-- and quotes (") are used for strings (not apostrophes).localcontent=get_page_content(modname)locallnum=0localcurrent_gameslocalitems=Collection.new()forlineinstring.gmatch(content,'(.-)\n')dolnum=lnum+1localindent,title=line:match('^(\t+)%["(.-)"%]')ifindentthenifindent=='\t'thencurrent_games=titleelseitems:add({competition=current_games,team=title,line=lnum,})endendendreturnitemsendlocalfunctionmain(frame)localtitle=frame.args[1]iftitle==nilortitle==''thenreturn'Error: Parameter 1 must specify name of data module'endlocalsandbox=title:find('sandbox',1,true)and'/sandbox'or''locallister=require('Module:Team appearances list'..sandbox)._mainlocallines=Collection.new()localcurrent_gamesfor_,iteminipairs(make_data(title))doifcurrent_games~=item.competitionthencurrent_games=item.competitionlines:add('=='..current_games..'==')endlines:add(item.team..' (line '..item.line..') '..lister(item))endreturnlines:join('\n')endreturn{main=main}