Tile - Array - Sort – Ylands
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "{{Ylands scripting navbox}}" to "{{Ylands editor navbox}}") |
Lou Montana (talk | contribs) m (Text replacement - "{{DEFAULTSORT:{{#sub:{{PAGENAME}}|14}}}}" to "{{DEFAULTSORT:{{#sub:{{PAGENAME}}|7}}}}") |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<!--- | |||
THIS PAGE WAS GENERATED AUTOMATICALLY; DO NOT EDIT IT, OTHERWISE YOUR CHANGES WILL BE LOST DURING FUTURE UPDATE. | |||
--> | |||
== Sort(Array, Compare instruction) == | |||
[[File:YlandsTile-755.png]] | |||
<pre>sort(comparator: (objectA: T, objectB: T) => any): void;</pre> | |||
=== Parameters === | |||
==== comparator ==== | |||
=== Availability === | |||
[[Ylands:Tile Availability - Client|Client]], [[Ylands:Tile Availability - Server|Server]], [[Ylands:Tile Availability - Custom Controller|Custom Controller]] | |||
=== Description === | |||
This instruction will '''sort''' the target '''array''' using a custom '''compare instruction'''. | |||
=== Notes === | |||
* When the instruction compares two values, it sends the values to the compare function, and sorts the values according to the returned (negative, zero, positive) value. | |||
'''Example:''' When comparing 40 and 100, the instruction calls the compare function(40,100). The function calculates 40-100, and returns -60 (a negative value). The sort function will sort 40 as a value lower than 100. | |||
* '''Object A''' - '''Object B''' results in an ascending sorting order. | |||
* '''Object B''' - ** Object A** results in a descending sorting order. | |||
---- | ---- | ||
{{Ylands | {{Navbox/Ylands}} | ||
{{DEFAULTSORT:{{#sub:{{PAGENAME}}| | {{DEFAULTSORT:{{#sub:{{PAGENAME}}|7}}}} | ||
[[Category: Instructions]] | [[Category: Instructions]] | ||
Latest revision as of 15:24, 24 November 2023
Sort(Array, Compare instruction)
sort(comparator: (objectA: T, objectB: T) => any): void;
Parameters
comparator
Availability
Client, Server, Custom Controller
Description
This instruction will sort the target array using a custom compare instruction.
Notes
- When the instruction compares two values, it sends the values to the compare function, and sorts the values according to the returned (negative, zero, positive) value.
Example: When comparing 40 and 100, the instruction calls the compare function(40,100). The function calculates 40-100, and returns -60 (a negative value). The sort function will sort 40 as a value lower than 100.
- Object A - Object B results in an ascending sorting order.
- Object B - ** Object A** results in a descending sorting order.