Tile - Array - Sort – Ylands

From Bohemia Interactive Community
Jump to navigation Jump to search
m (YlandsClassyBot moved page Ylands Tile - Sort array to Ylands:Tile - Array - Sort: New Structure)
No edit summary
Line 1: Line 1:
{{Wiki|stub}}
<!---
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) =&gt; any): void;</pre>
=== Parameters ===
 
==== comparator ====
 
=== 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.




Line 7: Line 30:


[[Category: Instructions]]
[[Category: Instructions]]
[[Category: Ylands 1.1]]

Revision as of 09:53, 8 July 2021

Sort(Array, Compare instruction)

YlandsTile-755.png

sort(comparator: (objectA: T, objectB: T) => any): void;

Parameters

comparator

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.