<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.figueroa.cc/index.php?action=history&amp;feed=atom&amp;title=Module%3ASortUtil</id>
	<title>Module:SortUtil - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.figueroa.cc/index.php?action=history&amp;feed=atom&amp;title=Module%3ASortUtil"/>
	<link rel="alternate" type="text/html" href="https://wiki.figueroa.cc/index.php?title=Module:SortUtil&amp;action=history"/>
	<updated>2026-12-03T09:54:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.13</generator>
	<entry>
		<id>https://wiki.figueroa.cc/index.php?title=Module:SortUtil&amp;diff=266&amp;oldid=prev</id>
		<title>imported&gt;RheingoldRiver: Created page with &quot;local util_args = require(&#039;Module:ArgsUtil&#039;) local util_table = require(&#039;Module:TableUtil&#039;)  local lang = mw.getLanguage(&#039;en&#039;)  local h = {} function h.compareTwoArraysByKeys(...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.figueroa.cc/index.php?title=Module:SortUtil&amp;diff=266&amp;oldid=prev"/>
		<updated>2020-10-12T06:15:20Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local util_args = require(&amp;#039;Module:ArgsUtil&amp;#039;) local util_table = require(&amp;#039;Module:TableUtil&amp;#039;)  local lang = mw.getLanguage(&amp;#039;en&amp;#039;)  local h = {} function h.compareTwoArraysByKeys(...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local util_args = require(&amp;#039;Module:ArgsUtil&amp;#039;)&lt;br /&gt;
local util_table = require(&amp;#039;Module:TableUtil&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local lang = mw.getLanguage(&amp;#039;en&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local h = {}&lt;br /&gt;
function h.compareTwoArraysByKeys(a, b, keyTbl, incTbl, i)&lt;br /&gt;
	if i &amp;gt; #keyTbl then return nil end&lt;br /&gt;
	local thisKey = keyTbl[i]&lt;br /&gt;
	if a[thisKey] == b[thisKey] or not a[thisKey] or not b[thisKey] then&lt;br /&gt;
		return h.compareTwoArraysByKeys(a, b, keyTbl, incTbl, i+1)&lt;br /&gt;
	end&lt;br /&gt;
	return h.compareNumberOrString(a[thisKey], b[thisKey], incTbl[i])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function h.compareNumberOrString(a, b, increasing)&lt;br /&gt;
	if increasing then return h.compareNumberOrString(b, a, false) end&lt;br /&gt;
	if tonumber(a) and tonumber(b) then&lt;br /&gt;
		return tonumber(a) &amp;gt; tonumber(b)&lt;br /&gt;
	end&lt;br /&gt;
	return lang:caseFold(a) &amp;gt; lang:caseFold(b)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.tablesByKeys(tbl, key, increasing)&lt;br /&gt;
	local keyTbl = util_table.guaranteeTable(key)&lt;br /&gt;
	local incTbl = util_table.guaranteeTable(increasing) or {}&lt;br /&gt;
	table.sort(tbl,&lt;br /&gt;
		function(a,b)&lt;br /&gt;
			return h.compareTwoArraysByKeys(a, b, keyTbl, incTbl, 1)&lt;br /&gt;
		end)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.dictByKeys(tbl, key, increasing)&lt;br /&gt;
	local keyTbl = util_table.guaranteeTable(key)&lt;br /&gt;
	local incTbl = util_table.guaranteeTable(increasing) or {}&lt;br /&gt;
	table.sort(tbl,&lt;br /&gt;
		function(a,b)&lt;br /&gt;
			local result = h.compareTwoArraysByKeys(tbl[a], tbl[b], keyTbl, incTbl, 1)&lt;br /&gt;
			if result == nil then&lt;br /&gt;
				return a &amp;lt; b&lt;br /&gt;
			end&lt;br /&gt;
			return result&lt;br /&gt;
		end)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.sortConstantDictionary(tbl)&lt;br /&gt;
	table.sort(tbl,&lt;br /&gt;
		function(a,b)&lt;br /&gt;
			return h.compareNumberOrString(tbl[a], tbl[b])&lt;br /&gt;
		end)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;RheingoldRiver</name></author>
	</entry>
</feed>