<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kezoto</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kezoto"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Kezoto"/>
	<updated>2026-06-04T12:10:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlignment&amp;diff=76174</id>
		<title>DgsCheckBoxSetButtonAlignment</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlignment&amp;diff=76174"/>
		<updated>2023-02-05T16:01:47Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlignment&amp;diff=76137</id>
		<title>DgsCheckBoxSetButtonAlignment</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlignment&amp;diff=76137"/>
		<updated>2023-02-05T13:36:06Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets the alignment of the button of a dgs check box.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool dgsCheckBoxSetButtonAlignment(element checkBox, string relative[, string side = &amp;quot;left&amp;quot;])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''checkBox:''' The dgs check box to set the vertical alignment.&lt;br /&gt;
*'''relative:''' The object the dgs check box's button is relative to. Valid type strings are:&lt;br /&gt;
**&amp;quot;text&amp;quot;: The dgs check box will be relative to the dgs check box's text.&lt;br /&gt;
**&amp;quot;boundingBox&amp;quot;: The dgs check box will be aligned from dgs check box's bounding box.&lt;br /&gt;
*'''side:''' The side the dgs check box's button is aligned to. Valid type strings are:&lt;br /&gt;
**&amp;quot;left&amp;quot;: The dgs check box will be aligned to the left, relative to relative object.&lt;br /&gt;
**&amp;quot;right&amp;quot;: The dgs check box will be aligned to the right, relative to relative object.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local cb1 = DGS:dgsCreateCheckBox(500,500,200,30,&amp;quot;aaaa&amp;quot;,false)&lt;br /&gt;
local cb2 = DGS:dgsCreateCheckBox(500,520,200,30,&amp;quot;bbbb&amp;quot;,false)&lt;br /&gt;
DGS:dgsCheckBoxSetButtonAlignment( cb1, &amp;quot;text&amp;quot;, &amp;quot;left&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlignment&amp;diff=76136</id>
		<title>DgsCheckBoxSetButtonAlignment</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlignment&amp;diff=76136"/>
		<updated>2023-02-05T13:35:31Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets the alignment of the button of a dgs check box.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool dgsCheckBoxSetButtonAlignment(element dgsElement, string relative[, string side = &amp;quot;left&amp;quot;])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''checkBox:''' The dgs check box to set the vertical alignment.&lt;br /&gt;
*'''relative:''' The object the dgs check box's button is relative to. Valid type strings are:&lt;br /&gt;
**&amp;quot;text&amp;quot;: The dgs check box will be relative to the dgs check box's text.&lt;br /&gt;
**&amp;quot;boundingBox&amp;quot;: The dgs check box will be aligned from dgs check box's bounding box.&lt;br /&gt;
*'''side:''' The side the dgs check box's button is aligned to. Valid type strings are:&lt;br /&gt;
**&amp;quot;left&amp;quot;: The dgs check box will be aligned to the left, relative to relative object.&lt;br /&gt;
**&amp;quot;right&amp;quot;: The dgs check box will be aligned to the right, relative to relative object.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local cb1 = DGS:dgsCreateCheckBox(500,500,200,30,&amp;quot;aaaa&amp;quot;,false)&lt;br /&gt;
local cb2 = DGS:dgsCreateCheckBox(500,520,200,30,&amp;quot;bbbb&amp;quot;,false)&lt;br /&gt;
DGS:dgsCheckBoxSetButtonAlignment( cb1, &amp;quot;text&amp;quot;, &amp;quot;left&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsGetPositionAlignment&amp;diff=76135</id>
		<title>DgsGetPositionAlignment</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsGetPositionAlignment&amp;diff=76135"/>
		<updated>2023-02-05T13:34:30Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__{{Client function}}&lt;br /&gt;
&lt;br /&gt;
This function returns the alignment of position from a specific DGS element&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string, string dgsGetPositionAlignment( element dgsElement )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{DGS/OOP|&lt;br /&gt;
    Note = The '''Variable''' It's a table and has the following using:&lt;br /&gt;
* &amp;lt;code&amp;gt;positionAlignment[1]&amp;lt;/code&amp;gt; for '''horizontal''' alignment&lt;br /&gt;
* &amp;lt;code&amp;gt;positionAlignment[2]&amp;lt;/code&amp;gt; for '''vertical''' alignment|&lt;br /&gt;
    Method = DGSElement:getPositionAlignment|&lt;br /&gt;
    Variable = positionAlignment|&lt;br /&gt;
    Counterpart = dgsSetPositionAlignment&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''dgsElement:''' The DGS element to change the alignment.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Return two ''string''s, indicates '''horizontal''' and '''vertical''' alignment.&lt;br /&gt;
*'''horizontalAlignment''':&lt;br /&gt;
**'''left'''&lt;br /&gt;
**'''center'''&lt;br /&gt;
**'''right'''&lt;br /&gt;
*'''verticalAlignment''':&lt;br /&gt;
**'''top'''&lt;br /&gt;
**'''center'''&lt;br /&gt;
**'''bottom'''&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
&lt;br /&gt;
local window = DGS:dgsCreateWindow(0.40, 0.33, 0.20, 0.21, &amp;quot;DGS Window&amp;quot;, true)&lt;br /&gt;
local button = DGS:dgsCreateButton(0.0, 0.0, 0.2, 0.1, &amp;quot;Ok&amp;quot;, true, window)&lt;br /&gt;
&lt;br /&gt;
local hAlign,vAlign = DGS:dgsGetPositionAlignment(button)&lt;br /&gt;
outputChatBox(hAlign..&amp;quot;-&amp;quot;..vAlibn)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;span style=&amp;quot;color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;&amp;quot;&amp;gt;General Functions&amp;lt;/span&amp;gt;==&lt;br /&gt;
{{DGS General Functions}}&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;span style=&amp;quot;color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;&amp;quot;&amp;gt;General Events&amp;lt;/span&amp;gt;==&lt;br /&gt;
{{DGS Events/General}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxGetButtonAlign&amp;diff=76134</id>
		<title>DgsCheckBoxGetButtonAlign</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxGetButtonAlign&amp;diff=76134"/>
		<updated>2023-02-05T13:33:21Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Created blank page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlignment&amp;diff=76133</id>
		<title>DgsCheckBoxSetButtonAlignment</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlignment&amp;diff=76133"/>
		<updated>2023-02-05T13:33:06Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Created page with &amp;quot;{{Client function}} __NOTOC__ This function sets the alignment of the button of a dgs check box.  ==Syntax==  &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool dgsCheckBoxSetButtonAlignment(dgsCheckBox, string relative[, string side = &amp;quot;left&amp;quot;]) &amp;lt;/syntaxhighlight&amp;gt;   ===Required Arguments===  *'''checkBox:''' The dgs check box to set the vertical alignment. *'''relative:''' The object the dgs check box's button is relative to. Valid type strings are: **&amp;quot;text&amp;quot;: The dgs check box will be rel...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets the alignment of the button of a dgs check box.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool dgsCheckBoxSetButtonAlignment(dgsCheckBox, string relative[, string side = &amp;quot;left&amp;quot;])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''checkBox:''' The dgs check box to set the vertical alignment.&lt;br /&gt;
*'''relative:''' The object the dgs check box's button is relative to. Valid type strings are:&lt;br /&gt;
**&amp;quot;text&amp;quot;: The dgs check box will be relative to the dgs check box's text.&lt;br /&gt;
**&amp;quot;boundingBox&amp;quot;: The dgs check box will be aligned from dgs check box's bounding box.&lt;br /&gt;
*'''side:''' The side the dgs check box's button is aligned to. Valid type strings are:&lt;br /&gt;
**&amp;quot;left&amp;quot;: The dgs check box will be aligned to the left, relative to relative object.&lt;br /&gt;
**&amp;quot;right&amp;quot;: The dgs check box will be aligned to the right, relative to relative object.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local cb1 = DGS:dgsCreateCheckBox(500,500,200,30,&amp;quot;aaaa&amp;quot;,false)&lt;br /&gt;
local cb2 = DGS:dgsCreateCheckBox(500,520,200,30,&amp;quot;bbbb&amp;quot;,false)&lt;br /&gt;
DGS:dgsCheckBoxSetButtonAlignment( cb1, &amp;quot;text&amp;quot;, &amp;quot;left&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlign&amp;diff=76132</id>
		<title>DgsCheckBoxSetButtonAlign</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlign&amp;diff=76132"/>
		<updated>2023-02-05T13:27:12Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets the alignment of the button of a dgs check box.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool dgsCheckBoxSetButtonAlign(dgsCheckBox, string relative[, string side = &amp;quot;left&amp;quot;])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''checkBox:''' The dgs check box to set the vertical alignment.&lt;br /&gt;
*'''relative:''' The object the dgs check box's button is relative to. Valid type strings are:&lt;br /&gt;
**&amp;quot;text&amp;quot;: The dgs check box will be relative to the dgs check box's text.&lt;br /&gt;
**&amp;quot;boundingBox&amp;quot;: The dgs check box will be aligned from dgs check box's bounding box.&lt;br /&gt;
*'''side:''' The side the dgs check box's button is aligned to. Valid type strings are:&lt;br /&gt;
**&amp;quot;left&amp;quot;: The dgs check box will be aligned to the left, relative to relative object.&lt;br /&gt;
**&amp;quot;right&amp;quot;: The dgs check box will be aligned to the right, relative to relative object.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local cb1 = DGS:dgsCreateCheckBox(500,500,200,30,&amp;quot;aaaa&amp;quot;,false)&lt;br /&gt;
local cb2 = DGS:dgsCreateCheckBox(500,520,200,30,&amp;quot;bbbb&amp;quot;,false)&lt;br /&gt;
DGS:dgsCheckBoxSetButtonAlign( cb1, &amp;quot;text&amp;quot;, &amp;quot;left&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlign&amp;diff=76131</id>
		<title>DgsCheckBoxSetButtonAlign</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlign&amp;diff=76131"/>
		<updated>2023-02-05T13:25:37Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets the alignment of the button of a dgs check box.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool dgsCheckBoxSetButtonAlign(dgsCheckBox, string relative[, string side = &amp;quot;left&amp;quot;])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''checkBox:''' The dgs check box to set the vertical alignment.&lt;br /&gt;
*'''relative:''' The object the dgs check box's button is relative to. Valid type strings are:&lt;br /&gt;
**&amp;quot;text&amp;quot;: The dgs check box will be relative to the dgs check box's text.&lt;br /&gt;
**&amp;quot;boundingBox&amp;quot;: The dgs check box will be aligned from dgs check box's bounding box.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local cb1 = DGS:dgsCreateCheckBox(500,500,200,30,&amp;quot;aaaa&amp;quot;,false)&lt;br /&gt;
local cb2 = DGS:dgsCreateCheckBox(500,520,200,30,&amp;quot;bbbb&amp;quot;,false)&lt;br /&gt;
DGS:dgsCheckBoxSetButtonAlign( cb1, &amp;quot;text&amp;quot;, &amp;quot;left&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlign&amp;diff=76130</id>
		<title>DgsCheckBoxSetButtonAlign</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsCheckBoxSetButtonAlign&amp;diff=76130"/>
		<updated>2023-02-05T13:24:10Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Created page with &amp;quot;{{Client function}} __NOTOC__ This function sets the alignment of the button of a dgs check box.  ==Syntax==  &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool dgsCheckBoxSetButtonAlign(dgsCheckBox, string alignment [, string side = &amp;quot;left&amp;quot;]) &amp;lt;/syntaxhighlight&amp;gt;   ===Required Arguments===  *'''checkBox:''' The dgs check box to set the vertical alignment. *'''relative:''' The object the dgs check box's button is relative to. Valid type strings are: **&amp;quot;text&amp;quot;: The dgs check box will be relat...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets the alignment of the button of a dgs check box.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool dgsCheckBoxSetButtonAlign(dgsCheckBox, string alignment [, string side = &amp;quot;left&amp;quot;])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''checkBox:''' The dgs check box to set the vertical alignment.&lt;br /&gt;
*'''relative:''' The object the dgs check box's button is relative to. Valid type strings are:&lt;br /&gt;
**&amp;quot;text&amp;quot;: The dgs check box will be relative to the dgs check box's text.&lt;br /&gt;
**&amp;quot;boundingBox&amp;quot;: The dgs check box will be aligned from dgs check box's bounding box.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if successful, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local cb1 = DGS:dgsCreateCheckBox(500,500,200,30,&amp;quot;aaaa&amp;quot;,false)&lt;br /&gt;
local cb2 = DGS:dgsCreateCheckBox(500,520,200,30,&amp;quot;bbbb&amp;quot;,false)&lt;br /&gt;
DGS:dgsCheckBoxSetButtonAlign( cb1, &amp;quot;text&amp;quot;, &amp;quot;left&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{DGSFUNCTIONS}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75353</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75353"/>
		<updated>2022-08-13T07:56:44Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Table.sortNumerically&amp;diff=75352</id>
		<title>Table.sortNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.sortNumerically&amp;diff=75352"/>
		<updated>2022-08-13T07:56:36Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function sorts tables by index numerically from largest to smallest or from smallest to largest. Its also useful for removing gaps from your table. &amp;lt;br&amp;gt; '''Important : WORKS ONLY FOR TABLES WITH NUMERIC INDEXES!''' &amp;lt;br&amp;gt;  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table table.sortNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments=== * '''theTable''': the table you would like to sort. ===O...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table table.sortNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function table.sortNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [9] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = table.sortNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = table.sortNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable3 = table.sortNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable3) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75351</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75351"/>
		<updated>2022-08-13T07:55:57Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table table.sortNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function table.sortNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [9] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = table.sortNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = table.sortNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable3 = table.sortNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable3) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75350</id>
		<title>DxDrawShadedText</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75350"/>
		<updated>2022-08-12T17:43:36Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function creates shadow effect for the dxText.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR DX TEXT!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table dxDrawShadedText( string text, float leftX, float topY, float rightX, float bottomY, int color, int shadowColor, float offsetX, float offsetY, float scaleXY = 1.0 [, float scaleY = 1.0 ],&lt;br /&gt;
                  mixed font = &amp;quot;default&amp;quot;, string alignX = &amp;quot;left&amp;quot;, string alignY = &amp;quot;top&amp;quot;, bool clip = false, bool wordBreak = false,&lt;br /&gt;
                  bool postGUI = false, bool colorCoded = false, bool subPixelPositioning = false,&lt;br /&gt;
                  float fRotation = 0.0, float fRotationCenterX = 0.0, float fRotationCenterY = 0.0, float fLineSpacing = 0.0] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''text:''' the text to draw&lt;br /&gt;
*'''leftX:''' the absolute X coordinate of the top left corner of the text&lt;br /&gt;
*'''topY:''' the absolute Y coordinate of the top left corner of the text&lt;br /&gt;
* '''color''': the color of your text.&lt;br /&gt;
* '''offsetX''': the number that offsets your text along the X axis.&lt;br /&gt;
* '''offsetY''': the number that offsets your text along the Y axis.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''shadowColor''': the color of the text shadow.&lt;br /&gt;
*'''rightX:''' the absolute X coordinate of the right side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''bottomY:''' the absolute Y coordinate of the bottom side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''color:''' the color of the text, a value produced by [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).&lt;br /&gt;
*'''scale:''' the size of the text.{{New feature|3.0110|1.1|'''scale:''' can (optionally) be specified as two floats. i.e. '''scaleX, scaleY'''}}&lt;br /&gt;
*'''font:''' Either a custom [[DX font]] element or the name of a built-in DX font: '''Note: Some fonts are incompatible with certain languages such as Arabic.'''&lt;br /&gt;
{{DxFonts}}&lt;br /&gt;
*'''alignX:''' horizontal alignment of the text within the bounding box. Can be '''&amp;quot;left&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;right&amp;quot;'''.&lt;br /&gt;
*'''alignY:''' vertical alignment of the text within the bounding box. Can be '''&amp;quot;top&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;bottom&amp;quot;'''.&lt;br /&gt;
*'''clip:''' if set to ''true'', the parts of the text that don't fit within the bounding box will be cut off.&lt;br /&gt;
*'''wordBreak:''' if set to ''true'', the text will wrap to a new line whenever it reaches the right side of the bounding box. If ''false'', the text will always be completely on one line.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
{{New feature/item|3.0130|1.3.0|3986|&lt;br /&gt;
*'''colorCoded:''' Set to true to enable embedded #FFFFFF color codes. '''Note: clip and wordBreak are forced false if this is set.'''&lt;br /&gt;
*'''subPixelPositioning:''' A bool representing whether the text can be positioned sub-pixel-ly. Looks nicer for moving/scaling animations.&lt;br /&gt;
}}&lt;br /&gt;
{{New feature/item|3.0135|1.3.5|6054|&lt;br /&gt;
*'''fRotation:''' Rotation'''&lt;br /&gt;
*'''fRotationCenterX:''' Rotation Origin X'''&lt;br /&gt;
*'''fRotationCenterY:''' Rotation Origin Y'''&lt;br /&gt;
}}&lt;br /&gt;
{{Added feature/item|1.5.9|1.5.8|20957|&lt;br /&gt;
*'''fLineSpacing:''' Distance in pixels between the lines of text, this can be a negative number, works only when '''colorCoded''' is set to true''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function dxDrawShadedText(text, leftX, topY, rightX, bottomY, color, shadowColor, offsetX, offsetY, ...)&lt;br /&gt;
    rightX = rightX or 0&lt;br /&gt;
    bottomY = bottomY or 0&lt;br /&gt;
    shadowColor = shadowColor or -16777216&lt;br /&gt;
    dxDrawText(text, leftX + offsetX, topY + offsetY, rightX + offsetX, rightX + offsetY, shadowColor, ...)&lt;br /&gt;
    dxDrawText(text, leftX, topY, rightX, rightX, color, ...)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will create shadow for the text.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, function()&lt;br /&gt;
    dxDrawShadedText(&amp;quot;Hello World!&amp;quot;, 0, 0, nil, nil, tocolor(255, 255, 255), nil, 1, 1)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75349</id>
		<title>DxDrawShadedText</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75349"/>
		<updated>2022-08-12T17:42:44Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function creates shadow effect for the dxText.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR DX TEXT!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table dxDrawShadedText( string text, float leftX, float topY, float rightX, float bottomY, int color, int shadowColor, float offsetX, number float)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''text:''' the text to draw&lt;br /&gt;
*'''leftX:''' the absolute X coordinate of the top left corner of the text&lt;br /&gt;
*'''topY:''' the absolute Y coordinate of the top left corner of the text&lt;br /&gt;
* '''color''': the color of your text.&lt;br /&gt;
* '''offsetX''': the number that offsets your text along the X axis.&lt;br /&gt;
* '''offsetY''': the number that offsets your text along the Y axis.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''shadowColor''': the color of the text shadow.&lt;br /&gt;
*'''rightX:''' the absolute X coordinate of the right side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''bottomY:''' the absolute Y coordinate of the bottom side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''color:''' the color of the text, a value produced by [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).&lt;br /&gt;
*'''scale:''' the size of the text.{{New feature|3.0110|1.1|'''scale:''' can (optionally) be specified as two floats. i.e. '''scaleX, scaleY'''}}&lt;br /&gt;
*'''font:''' Either a custom [[DX font]] element or the name of a built-in DX font: '''Note: Some fonts are incompatible with certain languages such as Arabic.'''&lt;br /&gt;
{{DxFonts}}&lt;br /&gt;
*'''alignX:''' horizontal alignment of the text within the bounding box. Can be '''&amp;quot;left&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;right&amp;quot;'''.&lt;br /&gt;
*'''alignY:''' vertical alignment of the text within the bounding box. Can be '''&amp;quot;top&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;bottom&amp;quot;'''.&lt;br /&gt;
*'''clip:''' if set to ''true'', the parts of the text that don't fit within the bounding box will be cut off.&lt;br /&gt;
*'''wordBreak:''' if set to ''true'', the text will wrap to a new line whenever it reaches the right side of the bounding box. If ''false'', the text will always be completely on one line.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
{{New feature/item|3.0130|1.3.0|3986|&lt;br /&gt;
*'''colorCoded:''' Set to true to enable embedded #FFFFFF color codes. '''Note: clip and wordBreak are forced false if this is set.'''&lt;br /&gt;
*'''subPixelPositioning:''' A bool representing whether the text can be positioned sub-pixel-ly. Looks nicer for moving/scaling animations.&lt;br /&gt;
}}&lt;br /&gt;
{{New feature/item|3.0135|1.3.5|6054|&lt;br /&gt;
*'''fRotation:''' Rotation'''&lt;br /&gt;
*'''fRotationCenterX:''' Rotation Origin X'''&lt;br /&gt;
*'''fRotationCenterY:''' Rotation Origin Y'''&lt;br /&gt;
}}&lt;br /&gt;
{{Added feature/item|1.5.9|1.5.8|20957|&lt;br /&gt;
*'''fLineSpacing:''' Distance in pixels between the lines of text, this can be a negative number, works only when '''colorCoded''' is set to true''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function dxDrawShadedText(text, leftX, topY, rightX, bottomY, color, shadowColor, offsetX, offsetY, ...)&lt;br /&gt;
    rightX = rightX or 0&lt;br /&gt;
    bottomY = bottomY or 0&lt;br /&gt;
    shadowColor = shadowColor or -16777216&lt;br /&gt;
    dxDrawText(text, leftX + offsetX, topY + offsetY, rightX + offsetX, rightX + offsetY, shadowColor, ...)&lt;br /&gt;
    dxDrawText(text, leftX, topY, rightX, rightX, color, ...)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will create shadow for the text.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, function()&lt;br /&gt;
    dxDrawShadedText(&amp;quot;Hello World!&amp;quot;, 0, 0, nil, nil, tocolor(255, 255, 255), nil, 1, 1)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75348</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75348"/>
		<updated>2022-08-12T17:42:08Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [9] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable3 = sortTableNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable3) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75347</id>
		<title>DxDrawShadedText</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75347"/>
		<updated>2022-08-12T17:41:44Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function creates shadow effect for the dxText.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR DX TEXT!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table dxDrawShadedText( string text, float leftX, float topY, float rightX, float bottomY, int color, int shadowColor, float offsetX, number float)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''text''': the string with your text.&lt;br /&gt;
*'''text:''' the text to draw&lt;br /&gt;
*'''leftX:''' the absolute X coordinate of the top left corner of the text&lt;br /&gt;
*'''topY:''' the absolute Y coordinate of the top left corner of the text&lt;br /&gt;
* '''color''': the color of your text.&lt;br /&gt;
* '''offsetX''': the number that offsets your text along the X axis.&lt;br /&gt;
* '''offsetY''': the number that offsets your text along the Y axis.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''shadowColor''': the color of the text shadow.&lt;br /&gt;
*'''rightX:''' the absolute X coordinate of the right side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''bottomY:''' the absolute Y coordinate of the bottom side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''color:''' the color of the text, a value produced by [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).&lt;br /&gt;
*'''scale:''' the size of the text.{{New feature|3.0110|1.1|'''scale:''' can (optionally) be specified as two floats. i.e. '''scaleX, scaleY'''}}&lt;br /&gt;
*'''font:''' Either a custom [[DX font]] element or the name of a built-in DX font: '''Note: Some fonts are incompatible with certain languages such as Arabic.'''&lt;br /&gt;
{{DxFonts}}&lt;br /&gt;
*'''alignX:''' horizontal alignment of the text within the bounding box. Can be '''&amp;quot;left&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;right&amp;quot;'''.&lt;br /&gt;
*'''alignY:''' vertical alignment of the text within the bounding box. Can be '''&amp;quot;top&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;bottom&amp;quot;'''.&lt;br /&gt;
*'''clip:''' if set to ''true'', the parts of the text that don't fit within the bounding box will be cut off.&lt;br /&gt;
*'''wordBreak:''' if set to ''true'', the text will wrap to a new line whenever it reaches the right side of the bounding box. If ''false'', the text will always be completely on one line.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
{{New feature/item|3.0130|1.3.0|3986|&lt;br /&gt;
*'''colorCoded:''' Set to true to enable embedded #FFFFFF color codes. '''Note: clip and wordBreak are forced false if this is set.'''&lt;br /&gt;
*'''subPixelPositioning:''' A bool representing whether the text can be positioned sub-pixel-ly. Looks nicer for moving/scaling animations.&lt;br /&gt;
}}&lt;br /&gt;
{{New feature/item|3.0135|1.3.5|6054|&lt;br /&gt;
*'''fRotation:''' Rotation'''&lt;br /&gt;
*'''fRotationCenterX:''' Rotation Origin X'''&lt;br /&gt;
*'''fRotationCenterY:''' Rotation Origin Y'''&lt;br /&gt;
}}&lt;br /&gt;
{{Added feature/item|1.5.9|1.5.8|20957|&lt;br /&gt;
*'''fLineSpacing:''' Distance in pixels between the lines of text, this can be a negative number, works only when '''colorCoded''' is set to true''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function dxDrawShadedText(text, leftX, topY, rightX, bottomY, color, shadowColor, offsetX, offsetY, ...)&lt;br /&gt;
    rightX = rightX or 0&lt;br /&gt;
    bottomY = bottomY or 0&lt;br /&gt;
    shadowColor = shadowColor or -16777216&lt;br /&gt;
    dxDrawText(text, leftX + offsetX, topY + offsetY, rightX + offsetX, rightX + offsetY, shadowColor, ...)&lt;br /&gt;
    dxDrawText(text, leftX, topY, rightX, rightX, color, ...)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will create shadow for the text.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, function()&lt;br /&gt;
    dxDrawShadedText(&amp;quot;Hello World!&amp;quot;, 0, 0, nil, nil, tocolor(255, 255, 255), nil, 1, 1)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75346</id>
		<title>DxDrawShadedText</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75346"/>
		<updated>2022-08-12T17:40:32Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function creates shadow effect for the dxText.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR DX TEXT!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table dxDrawShadedText( string text, float leftX, float topY, float rightX, float bottomY, int color, int shadowColor, float offsetX, number float)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''text''': the string with your text.&lt;br /&gt;
*'''text:''' the text to draw&lt;br /&gt;
*'''leftX:''' the absolute X coordinate of the top left corner of the text&lt;br /&gt;
*'''topY:''' the absolute Y coordinate of the top left corner of the text&lt;br /&gt;
* '''color''': the color of your text.&lt;br /&gt;
* '''offsetX''': the number that offsets your text along the X axis.&lt;br /&gt;
* '''offsetY''': the number that offsets your text along the Y axis.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''shadowColor''': the color of the text shadow.&lt;br /&gt;
*'''rightX:''' the absolute X coordinate of the right side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''bottomY:''' the absolute Y coordinate of the bottom side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''color:''' the color of the text, a value produced by [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).&lt;br /&gt;
*'''scale:''' the size of the text.{{New feature|3.0110|1.1|'''scale:''' can (optionally) be specified as two floats. i.e. '''scaleX, scaleY'''}}&lt;br /&gt;
*'''font:''' Either a custom [[DX font]] element or the name of a built-in DX font: '''Note: Some fonts are incompatible with certain languages such as Arabic.'''&lt;br /&gt;
{{DxFonts}}&lt;br /&gt;
*'''alignX:''' horizontal alignment of the text within the bounding box. Can be '''&amp;quot;left&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;right&amp;quot;'''.&lt;br /&gt;
*'''alignY:''' vertical alignment of the text within the bounding box. Can be '''&amp;quot;top&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;bottom&amp;quot;'''.&lt;br /&gt;
*'''clip:''' if set to ''true'', the parts of the text that don't fit within the bounding box will be cut off.&lt;br /&gt;
*'''wordBreak:''' if set to ''true'', the text will wrap to a new line whenever it reaches the right side of the bounding box. If ''false'', the text will always be completely on one line.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
{{New feature/item|3.0130|1.3.0|3986|&lt;br /&gt;
*'''colorCoded:''' Set to true to enable embedded #FFFFFF color codes. '''Note: clip and wordBreak are forced false if this is set.'''&lt;br /&gt;
*'''subPixelPositioning:''' A bool representing whether the text can be positioned sub-pixel-ly. Looks nicer for moving/scaling animations.&lt;br /&gt;
}}&lt;br /&gt;
{{New feature/item|3.0135|1.3.5|6054|&lt;br /&gt;
*'''fRotation:''' Rotation'''&lt;br /&gt;
*'''fRotationCenterX:''' Rotation Origin X'''&lt;br /&gt;
*'''fRotationCenterY:''' Rotation Origin Y'''&lt;br /&gt;
}}&lt;br /&gt;
{{Added feature/item|1.5.9|1.5.8|20957|&lt;br /&gt;
*'''fLineSpacing:''' Distance in pixels between the lines of text, this can be a negative number, works only when '''colorCoded''' is set to true''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function dxDrawShadedText(text, leftX, topY, rightX, bottomY, color, shadowColor, offsetX, offsetY, ...)&lt;br /&gt;
    leftX = leftX or 0&lt;br /&gt;
    rightX = rightX or 0&lt;br /&gt;
    shadowColor = shadowColor or -16777216&lt;br /&gt;
    dxDrawText(text, leftX + offsetX, topY + offsetY, rightX + offsetX, rightX + offsetY, shadowColor, ...)&lt;br /&gt;
    dxDrawText(text, leftX, topY, rightX, rightX, color, ...)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will create shadow for the text.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, function()&lt;br /&gt;
    dxDrawShadedText(&amp;quot;Hello World!&amp;quot;, 0, 0, nil, nil, tocolor(255, 255, 255), nil, 1, 1)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75345</id>
		<title>DxDrawShadedText</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75345"/>
		<updated>2022-08-12T17:40:10Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function creates shadow effect for the dxText.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR DX TEXT!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table dxDrawShadedText( string text, float leftX, float topY, float rightX, float bottomY, color color, color shadowColor, float offsetX, number float)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''text''': the string with your text.&lt;br /&gt;
*'''text:''' the text to draw&lt;br /&gt;
*'''leftX:''' the absolute X coordinate of the top left corner of the text&lt;br /&gt;
*'''topY:''' the absolute Y coordinate of the top left corner of the text&lt;br /&gt;
* '''color''': the color of your text.&lt;br /&gt;
* '''offsetX''': the number that offsets your text along the X axis.&lt;br /&gt;
* '''offsetY''': the number that offsets your text along the Y axis.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''shadowColor''': the color of the text shadow.&lt;br /&gt;
*'''rightX:''' the absolute X coordinate of the right side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''bottomY:''' the absolute Y coordinate of the bottom side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''color:''' the color of the text, a value produced by [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).&lt;br /&gt;
*'''scale:''' the size of the text.{{New feature|3.0110|1.1|'''scale:''' can (optionally) be specified as two floats. i.e. '''scaleX, scaleY'''}}&lt;br /&gt;
*'''font:''' Either a custom [[DX font]] element or the name of a built-in DX font: '''Note: Some fonts are incompatible with certain languages such as Arabic.'''&lt;br /&gt;
{{DxFonts}}&lt;br /&gt;
*'''alignX:''' horizontal alignment of the text within the bounding box. Can be '''&amp;quot;left&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;right&amp;quot;'''.&lt;br /&gt;
*'''alignY:''' vertical alignment of the text within the bounding box. Can be '''&amp;quot;top&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;bottom&amp;quot;'''.&lt;br /&gt;
*'''clip:''' if set to ''true'', the parts of the text that don't fit within the bounding box will be cut off.&lt;br /&gt;
*'''wordBreak:''' if set to ''true'', the text will wrap to a new line whenever it reaches the right side of the bounding box. If ''false'', the text will always be completely on one line.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
{{New feature/item|3.0130|1.3.0|3986|&lt;br /&gt;
*'''colorCoded:''' Set to true to enable embedded #FFFFFF color codes. '''Note: clip and wordBreak are forced false if this is set.'''&lt;br /&gt;
*'''subPixelPositioning:''' A bool representing whether the text can be positioned sub-pixel-ly. Looks nicer for moving/scaling animations.&lt;br /&gt;
}}&lt;br /&gt;
{{New feature/item|3.0135|1.3.5|6054|&lt;br /&gt;
*'''fRotation:''' Rotation'''&lt;br /&gt;
*'''fRotationCenterX:''' Rotation Origin X'''&lt;br /&gt;
*'''fRotationCenterY:''' Rotation Origin Y'''&lt;br /&gt;
}}&lt;br /&gt;
{{Added feature/item|1.5.9|1.5.8|20957|&lt;br /&gt;
*'''fLineSpacing:''' Distance in pixels between the lines of text, this can be a negative number, works only when '''colorCoded''' is set to true''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function dxDrawShadedText(text, leftX, topY, rightX, bottomY, color, shadowColor, offsetX, offsetY, ...)&lt;br /&gt;
    leftX = leftX or 0&lt;br /&gt;
    rightX = rightX or 0&lt;br /&gt;
    shadowColor = shadowColor or -16777216&lt;br /&gt;
    dxDrawText(text, leftX + offsetX, topY + offsetY, rightX + offsetX, rightX + offsetY, shadowColor, ...)&lt;br /&gt;
    dxDrawText(text, leftX, topY, rightX, rightX, color, ...)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will create shadow for the text.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, function()&lt;br /&gt;
    dxDrawShadedText(&amp;quot;Hello World!&amp;quot;, 0, 0, nil, nil, tocolor(255, 255, 255), nil, 1, 1)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75344</id>
		<title>DxDrawShadedText</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DxDrawShadedText&amp;diff=75344"/>
		<updated>2022-08-12T17:39:31Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function creates shadow effect for the dxText. &amp;lt;br&amp;gt; '''Important : WORKS ONLY FOR DX TEXT!''' &amp;lt;br&amp;gt;  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table dxDrawShadedText( string text, number leftX, number topY, number rightX, number bottomY, color color, color shadowColor, number offsetX, number offsetY)&amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments=== * '''text''': the string with your text. *'''text:''' the text to draw *'''leftX:''' the absolute...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function creates shadow effect for the dxText.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR DX TEXT!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table dxDrawShadedText( string text, number leftX, number topY, number rightX, number bottomY, color color, color shadowColor, number offsetX, number offsetY)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''text''': the string with your text.&lt;br /&gt;
*'''text:''' the text to draw&lt;br /&gt;
*'''leftX:''' the absolute X coordinate of the top left corner of the text&lt;br /&gt;
*'''topY:''' the absolute Y coordinate of the top left corner of the text&lt;br /&gt;
* '''color''': the color of your text.&lt;br /&gt;
* '''offsetX''': the number that offsets your text along the X axis.&lt;br /&gt;
* '''offsetY''': the number that offsets your text along the Y axis.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''shadowColor''': the color of the text shadow.&lt;br /&gt;
*'''rightX:''' the absolute X coordinate of the right side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''bottomY:''' the absolute Y coordinate of the bottom side of the text bounding box. Used for text aligning, clipping and word breaking.&lt;br /&gt;
*'''color:''' the color of the text, a value produced by [[tocolor]] or 0xAARRGGBB (AA = alpha, RR = red, GG = green, BB = blue).&lt;br /&gt;
*'''scale:''' the size of the text.{{New feature|3.0110|1.1|'''scale:''' can (optionally) be specified as two floats. i.e. '''scaleX, scaleY'''}}&lt;br /&gt;
*'''font:''' Either a custom [[DX font]] element or the name of a built-in DX font: '''Note: Some fonts are incompatible with certain languages such as Arabic.'''&lt;br /&gt;
{{DxFonts}}&lt;br /&gt;
*'''alignX:''' horizontal alignment of the text within the bounding box. Can be '''&amp;quot;left&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;right&amp;quot;'''.&lt;br /&gt;
*'''alignY:''' vertical alignment of the text within the bounding box. Can be '''&amp;quot;top&amp;quot;''', '''&amp;quot;center&amp;quot;''' or '''&amp;quot;bottom&amp;quot;'''.&lt;br /&gt;
*'''clip:''' if set to ''true'', the parts of the text that don't fit within the bounding box will be cut off.&lt;br /&gt;
*'''wordBreak:''' if set to ''true'', the text will wrap to a new line whenever it reaches the right side of the bounding box. If ''false'', the text will always be completely on one line.&lt;br /&gt;
* '''postGUI:''' A bool representing whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI).&lt;br /&gt;
{{New feature/item|3.0130|1.3.0|3986|&lt;br /&gt;
*'''colorCoded:''' Set to true to enable embedded #FFFFFF color codes. '''Note: clip and wordBreak are forced false if this is set.'''&lt;br /&gt;
*'''subPixelPositioning:''' A bool representing whether the text can be positioned sub-pixel-ly. Looks nicer for moving/scaling animations.&lt;br /&gt;
}}&lt;br /&gt;
{{New feature/item|3.0135|1.3.5|6054|&lt;br /&gt;
*'''fRotation:''' Rotation'''&lt;br /&gt;
*'''fRotationCenterX:''' Rotation Origin X'''&lt;br /&gt;
*'''fRotationCenterY:''' Rotation Origin Y'''&lt;br /&gt;
}}&lt;br /&gt;
{{Added feature/item|1.5.9|1.5.8|20957|&lt;br /&gt;
*'''fLineSpacing:''' Distance in pixels between the lines of text, this can be a negative number, works only when '''colorCoded''' is set to true''&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function dxDrawShadedText(text, leftX, topY, rightX, bottomY, color, shadowColor, offsetX, offsetY, ...)&lt;br /&gt;
    leftX = leftX or 0&lt;br /&gt;
    rightX = rightX or 0&lt;br /&gt;
    shadowColor = shadowColor or -16777216&lt;br /&gt;
    dxDrawText(text, leftX + offsetX, topY + offsetY, rightX + offsetX, rightX + offsetY, shadowColor, ...)&lt;br /&gt;
    dxDrawText(text, leftX, topY, rightX, rightX, color, ...)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will create shadow for the text.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, function()&lt;br /&gt;
    dxDrawShadedText(&amp;quot;Hello World!&amp;quot;, 0, 0, nil, nil, tocolor(255, 255, 255), nil, 1, 1)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75343</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75343"/>
		<updated>2022-08-12T17:21:08Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : WORKS ONLY FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [9] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable3 = sortTableNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable3) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75322</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75322"/>
		<updated>2022-07-31T17:21:42Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
===Author===&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [9] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable3 = sortTableNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable3) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75321</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=75321"/>
		<updated>2022-07-31T17:21:07Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Author==&lt;br /&gt;
Kezoto&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [9] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable3 = sortTableNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable3) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74707</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74707"/>
		<updated>2022-06-01T13:48:10Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [9] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable3 = sortTableNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable3) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74706</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74706"/>
		<updated>2022-06-01T13:47:24Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [9] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable3 = sortTableNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74705</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74705"/>
		<updated>2022-06-01T13:46:58Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
local sortedTable3 = sortTableNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74704</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74704"/>
		<updated>2022-06-01T13:46:33Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
Its also useful for removing gaps from your table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local theTable2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;}&lt;br /&gt;
local sortedTable3 = sortTableNumerically(theTable2, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74703</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=74703"/>
		<updated>2022-06-01T13:42:19Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or from smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=InsertValueBetweenIndexesInTable&amp;diff=73605</id>
		<title>InsertValueBetweenIndexesInTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=InsertValueBetweenIndexesInTable&amp;diff=73605"/>
		<updated>2022-01-18T18:30:38Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=InsertValueBetweenIndexesInTable&amp;diff=73604</id>
		<title>InsertValueBetweenIndexesInTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=InsertValueBetweenIndexesInTable&amp;diff=73604"/>
		<updated>2022-01-18T17:52:23Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function places the index among other indexes in the table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table insertValueBetweenIndexesInTable( table theTable, int index, var value )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': The table you want the index to be placed on.&lt;br /&gt;
* '''index''': The index where you want to put the value.&lt;br /&gt;
* '''value''': The value you want to put in the selected index.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns indexed table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function insertValueBetweenIndexesInTable(theTable, index, value)&lt;br /&gt;
    local otherValues = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(theTable) do&lt;br /&gt;
        if k &amp;gt;= index then&lt;br /&gt;
            otherValues[k+1] = v&lt;br /&gt;
            theTable[k] = nil&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    for k,v in pairs(otherValues) do&lt;br /&gt;
        theTable[k] = v&lt;br /&gt;
    end&lt;br /&gt;
    theTable[index] = value&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below prints table with an index placed between other indexes.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function insertValueBetweenIndexesInTable(theTable, index, value)&lt;br /&gt;
    local otherValues = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(theTable) do&lt;br /&gt;
        if k &amp;gt;= index then&lt;br /&gt;
            otherValues[k+1] = v&lt;br /&gt;
            theTable[k] = nil&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    for k,v in pairs(otherValues) do&lt;br /&gt;
        theTable[k] = v&lt;br /&gt;
    end&lt;br /&gt;
    theTable[index] = value&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {&lt;br /&gt;
    [1] = &amp;quot;Apple&amp;quot;,&lt;br /&gt;
    [2] = &amp;quot;Peach&amp;quot;,&lt;br /&gt;
    [3] = &amp;quot;Banana&amp;quot;,&lt;br /&gt;
    [4] = &amp;quot;Grape&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
local indexedTable = insertValueBetweenIndexesInTable(theTable, 3, &amp;quot;Orange&amp;quot;)&lt;br /&gt;
iprint(indexedTable) -- {&amp;quot;Apple&amp;quot;, &amp;quot;Peach&amp;quot;, &amp;quot;Orange&amp;quot;, &amp;quot;Banana&amp;quot;, &amp;quot;Grape&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=InsertValueBetweenIndexesInTable&amp;diff=73603</id>
		<title>InsertValueBetweenIndexesInTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=InsertValueBetweenIndexesInTable&amp;diff=73603"/>
		<updated>2022-01-18T17:50:26Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function places the index among other indexes in the table. &amp;lt;br&amp;gt; '''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!''' &amp;lt;br&amp;gt;  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table insertValueBetweenIndexesInTable( table theTable, int index, value )&amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments=== * '''theTable''': The table you want the index to be placed on. * '''index''': The index where you want to put the value. * '''value''': The value yo...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function places the index among other indexes in the table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table insertValueBetweenIndexesInTable( table theTable, int index, value )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': The table you want the index to be placed on.&lt;br /&gt;
* '''index''': The index where you want to put the value.&lt;br /&gt;
* '''value''': The value you want to put in the selected index.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns indexed table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function insertValueBetweenIndexesInTable(theTable, index, value)&lt;br /&gt;
    local otherValues = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(theTable) do&lt;br /&gt;
        if k &amp;gt;= index then&lt;br /&gt;
            otherValues[k+1] = v&lt;br /&gt;
            theTable[k] = nil&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    for k,v in pairs(otherValues) do&lt;br /&gt;
        theTable[k] = v&lt;br /&gt;
    end&lt;br /&gt;
    theTable[index] = value&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below prints table with an index placed between other indexes.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function insertValueBetweenIndexesInTable(theTable, index, value)&lt;br /&gt;
    local otherValues = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(theTable) do&lt;br /&gt;
        if k &amp;gt;= index then&lt;br /&gt;
            otherValues[k+1] = v&lt;br /&gt;
            theTable[k] = nil&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    for k,v in pairs(otherValues) do&lt;br /&gt;
        theTable[k] = v&lt;br /&gt;
    end&lt;br /&gt;
    theTable[index] = value&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {&lt;br /&gt;
    [1] = &amp;quot;Apple&amp;quot;,&lt;br /&gt;
    [2] = &amp;quot;Peach&amp;quot;,&lt;br /&gt;
    [3] = &amp;quot;Banana&amp;quot;,&lt;br /&gt;
    [4] = &amp;quot;Grape&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
local indexedTable = insertValueBetweenIndexesInTable(theTable, 3, &amp;quot;Orange&amp;quot;)&lt;br /&gt;
iprint(indexedTable) -- {&amp;quot;Apple&amp;quot;, &amp;quot;Peach&amp;quot;, &amp;quot;Orange&amp;quot;, &amp;quot;Banana&amp;quot;, &amp;quot;Grape&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73602</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73602"/>
		<updated>2022-01-18T17:46:31Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73601</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73601"/>
		<updated>2022-01-18T17:42:33Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local theTable = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(theTable, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(theTable, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73600</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73600"/>
		<updated>2022-01-18T17:39:05Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTable, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tableToSort = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(tableToSort, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(tableToSort, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73599</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73599"/>
		<updated>2022-01-18T17:38:48Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTable, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTable) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTable = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTable, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTable&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tableToSort = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(tableToSort, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(tableToSort, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsPedDiving&amp;diff=73593</id>
		<title>IsPedDiving</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsPedDiving&amp;diff=73593"/>
		<updated>2022-01-17T15:01:46Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function checks if the ped is diving in the water.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS CLIENT SIDE.'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool isPedDiving( ped thePedToCheck )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''thePedToCheck''': The ped element.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns true if ped is diving in water, false if not.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function isPedDiving(thePedToCheck)&lt;br /&gt;
	if isElement(thePedToCheck) then&lt;br /&gt;
		if getElementType(thePedToCheck) == &amp;quot;player&amp;quot; or getElementType(thePedToCheck) == &amp;quot;ped&amp;quot; then&lt;br /&gt;
			if getPedSimplestTask(thePedToCheck) == &amp;quot;TASK_SIMPLE_SWIM&amp;quot; and getPedTask(thePedToCheck, &amp;quot;primary&amp;quot;, 2) == &amp;quot;TASK_COMPLEX_IN_WATER&amp;quot; then&lt;br /&gt;
    				local x, y, z = getPedBonePosition(thePedToCheck, 8 )&lt;br /&gt;
    				local groundPosition, waterLevel = getGroundPosition(x, y, z), getWaterLevel (x, y, z, true)&lt;br /&gt;
    				return (groundPosition+waterLevel)-(groundPosition-z-0.5) &amp;lt; 0&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The example shows if the player is diving in the water when he presses b.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function checkDiving()&lt;br /&gt;
	if isPedDiving(localPlayer) then&lt;br /&gt;
		outputChatBox(&amp;quot;You are currently diving&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		outputChatBox(&amp;quot;You are not currently diving&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
bindKey(&amp;quot;b&amp;quot;, &amp;quot;down&amp;quot;, checkDiving)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73419</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73419"/>
		<updated>2022-01-15T22:33:44Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tableToSort = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable = sortTableNumerically(tableToSort, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(tableToSort, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73418</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73418"/>
		<updated>2022-01-15T22:33:25Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tableToSort = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
local sortedTable = sortTableNumerically(tableToSort, true)&lt;br /&gt;
iprint(sortedTable) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local sortedTable2 = sortTableNumerically(tableToSort, false)&lt;br /&gt;
iprint(sortedTable2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Rattle&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73417</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73417"/>
		<updated>2022-01-15T22:30:12Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables2, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73412</id>
		<title>SortTableNumerically</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortTableNumerically&amp;diff=73412"/>
		<updated>2022-01-15T22:21:28Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function sorts tables by index numerically from largest to smallest or smallest to largest. &amp;lt;br&amp;gt; '''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!''' &amp;lt;br&amp;gt;  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments=== * '''theTableToSort''': the table you would like to sort. ===Optional Arguments=== * '''fromHighestToLowest'...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73411</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73411"/>
		<updated>2022-01-15T22:21:25Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73410</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73410"/>
		<updated>2022-01-15T22:19:07Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73409</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73409"/>
		<updated>2022-01-15T22:18:57Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73408</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73408"/>
		<updated>2022-01-15T22:18:37Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Shared script&amp;quot; class=&amp;quot;shared&amp;quot; show=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73407</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73407"/>
		<updated>2022-01-15T22:17:51Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;&amp;quot; class=&amp;quot;shared&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73406</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73406"/>
		<updated>2022-01-15T22:16:52Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Shared script&amp;quot; class=&amp;quot;shared&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73405</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73405"/>
		<updated>2022-01-15T22:16:24Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;shared&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct sorted order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73404</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73404"/>
		<updated>2022-01-15T22:16:00Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;shared&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The code below will print the table in the correct order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true)&lt;br /&gt;
iprint(tables) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false)&lt;br /&gt;
iprint(tables2) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73403</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73403"/>
		<updated>2022-01-15T22:13:40Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;shared&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The example shows if the player is diving in the water when he presses b.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73402</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73402"/>
		<updated>2022-01-15T22:13:01Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!.'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;shared&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The example shows if the player is diving in the water when he presses b.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73401</id>
		<title>SortPairsTable</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=SortPairsTable&amp;diff=73401"/>
		<updated>2022-01-15T22:12:32Z</updated>

		<summary type="html">&lt;p&gt;Kezoto: Created page with &amp;quot;{{Useful Function}} __NOTOC__ This function sorts tables by index numerically from largest to smallest or smallest to largest. &amp;lt;br&amp;gt; '''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!.''' &amp;lt;br&amp;gt;  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments=== * '''theTableToSort''': the table you would like to sort. ===Optional Arguments=== * '''fromHighestToLowest...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sorts tables by index numerically from largest to smallest or smallest to largest.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Important : ONLY WORKS FOR TABLES WITH NUMERIC INDEXES!.'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table sortTableNumerically( table theTableToSort, bool fromHighestToLowest = false)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTableToSort''': the table you would like to sort.&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''fromHighestToLowest''': a bool representing whether the table is to be sorted by index from highest to lowest or lowest to highest.&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns sorted table.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Clientside script&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
The example shows if the player is diving in the water when he presses b.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function sortTableNumerically(theTableToSort, fromHighestToLowest)&lt;br /&gt;
    local sortTable = { }&lt;br /&gt;
    for k, v in pairs(theTableToSort) do&lt;br /&gt;
        table.insert(sortTable, {k, v})&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    table.sort(sortTable, function(a,b)&lt;br /&gt;
        local result = a[1]&amp;lt;b[1] &lt;br /&gt;
        if fromHighestToLowest then&lt;br /&gt;
            result = a[1]&amp;gt;b[1]&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
    theTableToSort = {}&lt;br /&gt;
&lt;br /&gt;
    for k,v in ipairs(sortTable) do&lt;br /&gt;
        table.insert(theTableToSort, v[2])&lt;br /&gt;
    end&lt;br /&gt;
    return theTableToSort&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local tables = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;,[6] = &amp;quot;Rattle&amp;quot;, [4] = &amp;quot;Dog&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables = sortTableNumerically(tables, true) -- {&amp;quot;Rattle&amp;quot;, &amp;quot;Boat&amp;quot;, &amp;quot;Dog&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Doll&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local tables2 = {[3] = &amp;quot;Dino&amp;quot;, [1] = &amp;quot;Doll&amp;quot;, [2] = &amp;quot;Car&amp;quot;, [5] = &amp;quot;Boat&amp;quot;}&lt;br /&gt;
tables2 = sortTableNumerically(tables, false) -- {&amp;quot;Doll&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;Dino&amp;quot;, &amp;quot;Boat&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kezoto</name></author>
	</entry>
</feed>