<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mbwiki.stairwaygames.work/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AArray</id>
	<title>Module:Array - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mbwiki.stairwaygames.work/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AArray"/>
	<link rel="alternate" type="text/html" href="https://mbwiki.stairwaygames.work/w/index.php?title=Module:Array&amp;action=history"/>
	<updated>2026-04-13T12:16:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://mbwiki.stairwaygames.work/w/index.php?title=Module:Array&amp;diff=6832&amp;oldid=prev</id>
		<title>Admin coral island: Created page with &quot;--- Module copied from Genshin Impact wiki  local p = {} local lib = require(&#039;Module:Feature&#039;)  function p.main(frame) 	local args = require(&#039;Module:Arguments&#039;).getArgs(frame, { 		parentFirst = true, 		wrapper = { &#039;Template:Array&#039; } 	}) 	--mw.logObject(args,&#039;args&#039;) --debug 	return p._main(args, frame) end  function p._main(args, frame) 	local arrayString = args[1] or nil 	local separator = args[2] or nil 	local format = args[3] or nil 	local join = args[4] or &#039;&#039; 	local d...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mbwiki.stairwaygames.work/w/index.php?title=Module:Array&amp;diff=6832&amp;oldid=prev"/>
		<updated>2023-08-09T08:44:23Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--- Module copied from Genshin Impact wiki  local p = {} local lib = require(&amp;#039;Module:Feature&amp;#039;)  function p.main(frame) 	local args = require(&amp;#039;Module:Arguments&amp;#039;).getArgs(frame, { 		parentFirst = true, 		wrapper = { &amp;#039;Template:Array&amp;#039; } 	}) 	--mw.logObject(args,&amp;#039;args&amp;#039;) --debug 	return p._main(args, frame) end  function p._main(args, frame) 	local arrayString = args[1] or nil 	local separator = args[2] or nil 	local format = args[3] or nil 	local join = args[4] or &amp;#039;&amp;#039; 	local d...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--- Module copied from Genshin Impact wiki&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
local lib = require(&amp;#039;Module:Feature&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = require(&amp;#039;Module:Arguments&amp;#039;).getArgs(frame, {&lt;br /&gt;
		parentFirst = true,&lt;br /&gt;
		wrapper = { &amp;#039;Template:Array&amp;#039; }&lt;br /&gt;
	})&lt;br /&gt;
	--mw.logObject(args,&amp;#039;args&amp;#039;) --debug&lt;br /&gt;
	return p._main(args, frame)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args, frame)&lt;br /&gt;
	local arrayString = args[1] or nil&lt;br /&gt;
	local separator = args[2] or nil&lt;br /&gt;
	local format = args[3] or nil&lt;br /&gt;
	local join = args[4] or &amp;#039;&amp;#039;&lt;br /&gt;
	local dedupe = args[&amp;#039;dedupe&amp;#039;] or nil&lt;br /&gt;
	local sort = args[&amp;#039;sort&amp;#039;] or nil&lt;br /&gt;
	local sentence = args[&amp;#039;sentence&amp;#039;] or nil&lt;br /&gt;
	local template = args[&amp;#039;template&amp;#039;] or nil&lt;br /&gt;
	local prefix = args[&amp;#039;prefix&amp;#039;] or &amp;#039;&amp;#039;&lt;br /&gt;
	local suffix = args[&amp;#039;suffix&amp;#039;] or &amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	-- argument validation&lt;br /&gt;
	if arrayString == nil then return &amp;#039;&amp;#039; end&lt;br /&gt;
	if separator == nil then return error(&amp;#039;Second argument (separator) must not be empty.&amp;#039;) end&lt;br /&gt;
	if separator == &amp;#039;&amp;#039; then return error(&amp;#039;Second argument (separator) must not be empty string.&amp;#039;) end&lt;br /&gt;
	if format == nil then return error(&amp;#039;Third argument (format) must not be empty.&amp;#039;) end&lt;br /&gt;
	if format:find(&amp;#039;{item}&amp;#039;) == nil then return error(&amp;#039;Third argument (format) does not include {item}.&amp;#039;) end&lt;br /&gt;
&lt;br /&gt;
	-- split string to array&lt;br /&gt;
	local array = lib.split(arrayString, separator)&lt;br /&gt;
&lt;br /&gt;
	-- remove duplcates from array&lt;br /&gt;
	if dedupe == &amp;#039;1&amp;#039; then&lt;br /&gt;
		array = p._removeDuplicates(array)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- sort array&lt;br /&gt;
	if sort ~= nil then&lt;br /&gt;
		array = p._sort(array, sort)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- replace keywords in array&lt;br /&gt;
	for key, value in pairs(array) do&lt;br /&gt;
		local item = format&lt;br /&gt;
		item = item:gsub(&amp;#039;{item}&amp;#039;, value)&lt;br /&gt;
		item = item:gsub(&amp;#039;{newline}&amp;#039;, &amp;#039;\n&amp;#039;)&lt;br /&gt;
		item = item:gsub(&amp;#039;{index}&amp;#039;, key)&lt;br /&gt;
		array[key] = item&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- mw.logObject(array)&lt;br /&gt;
	&lt;br /&gt;
	-- create result array&lt;br /&gt;
	local result = &amp;#039;&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	-- join as sentence&lt;br /&gt;
	if sentence ~= nil then&lt;br /&gt;
		if #array == 0 then return &amp;#039;&amp;#039;&lt;br /&gt;
		elseif #array == 1 then return array[1]&lt;br /&gt;
		elseif #array == 2 then return array[1] .. &amp;#039; and &amp;#039; .. array[2]&lt;br /&gt;
		else&lt;br /&gt;
			local last = table.remove(array, #array)&lt;br /&gt;
			result = table.concat(array, &amp;#039;, &amp;#039;) .. &amp;#039;, and &amp;#039; .. last&lt;br /&gt;
		end&lt;br /&gt;
	-- join with join string&lt;br /&gt;
	else&lt;br /&gt;
		result = table.concat(array, join):gsub(&amp;#039;{newline}&amp;#039;, &amp;#039;\n&amp;#039;)--in case joining string contains keyword&lt;br /&gt;
	end&lt;br /&gt;
	result = prefix .. result .. suffix&lt;br /&gt;
	if template then&lt;br /&gt;
		result = result:gsub(&amp;#039;²{(.-)}²&amp;#039;,&amp;#039;{{%1}}&amp;#039;):gsub(&amp;#039;¦&amp;#039;,&amp;#039;|&amp;#039;)&lt;br /&gt;
		result = frame:preprocess(result)&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._removeDuplicates(arr)&lt;br /&gt;
	local hash = {}&lt;br /&gt;
	local res = {}&lt;br /&gt;
&lt;br /&gt;
	for _,v in ipairs(arr) do&lt;br /&gt;
	   if (not hash[v]) then&lt;br /&gt;
	       res[#res+1] = v&lt;br /&gt;
	       hash[v] = true&lt;br /&gt;
	   end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return res&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._sort(arr, dir)&lt;br /&gt;
	local order = nil&lt;br /&gt;
	if (dir == -1 or dir == &amp;#039;-1&amp;#039;) then&lt;br /&gt;
		order = function(tVal, a, b) return a &amp;gt; b end&lt;br /&gt;
	elseif (dir == 1 or dir == &amp;#039;1&amp;#039;) then&lt;br /&gt;
		order = function(tVal, a, b) return a &amp;lt; b end&lt;br /&gt;
	else&lt;br /&gt;
		return arr&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(arr, function(a, b) return order(t, a, b) end)&lt;br /&gt;
	return arr&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Admin coral island</name></author>
	</entry>
</feed>