CBA_fnc_selectBest

Description

Select best element from an array

Parameters

_arrayInput Array [Array]
_criteriaCode that is passed element and should return an integer value [Code]
_returndefault return value if array is empty (optional, default nil) [Any]

Returns

Element that scores the highest [Any]

Example

_result = [[2, -6, 4], {abs _x}] call CBA_fnc_selectBest;
// _result => -6
_result =  [[q1, q2], {-(t1 distance _x)}, objNull] call CBA_fnc_selectBest; // selects closest target (negative distance)
// _result => q1

Author

PabstMirror

Close