Page tree
Skip to end of metadata
Go to start of metadata




Introduced in

Version:3.4

Description

Description:Inserts an element (Number) into the appropriate position of an ordered array. If the passed array is unsorted, then the insertion position is undefined.
The passed array is not modified using a reference. Instead, a new array is returned.

Syntax

Syntax:[baseArray, insert, ascending] call fn_vbs_arrayInsertOrdered
Parameters:
  • baseArray: Array - Array to insert into.
  • insert: Number - Element to insert.
  • ascending: Boolean - Whether the baseArray order is ascending (true) or descending (false) (optional, default: true).
Return Value:Array - Original array, with new element added.

Warning

When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Category VBS Scripting Functions.

Examples

Examples:
_arr= [[1,5,6], 4] call fn_vbs_arrayInsertOrdered; // returns: [1,4,5,6]
_arr= [[10,3,1], 7, false] call fn_vbs_arrayInsertOrdered; // returns: [10,7,3,1]

Additional Information

See also: fn vbs arrayInsert, fn vbs arrayAdd
Multiplayer: 
Problems: 

Notes