Luft08 27 Posted April 5, 2020 I took a piece of code that Grumpy Old Man wrote and modified it to do what I needed. The modified code does indeed work. Now I would like to know why. Here is my modified code: { private _referencePos = _x; private _sortedByRange = [allMapMarkers,[],{_referencePos distanceSqr getMarkerPos _x},"ASCEND", {(_x select [0,3] == "wp_")}] call BIS_fnc_sortBy; _sortedByRange params ["_nearestMarker"]; private _townNameArray = _nearestMarker splitString "_"; private _wpPrefix = "wp_" + (_townNameArray select 1) + "_"; hint _wpPrefix; } forEach activePlayerArray; I wanted the code to get the closest marker that name begins with "wp_" which it does. I just don't understand this line: private _sortedByRange = [allMapMarkers,[],{_referencePos distanceSqr getMarkerPos _x},"ASCEND", {(_x select [0,3] == "wp_")}] call BIS_fnc_sortBy; In particular I don't understand where the "magic variable" _x is getting its data. It's not from the forEach which would return a player. I think its from the allMapMarkers but I don't know why as I don't see a looping structure. Share this post Link to post Share on other sites
opusfmspol 280 Posted April 5, 2020 It's from allMapMarkers, and not from the forEach. It's from an apply in BIS_fnc_sortBy. Using the debug console function viewer, you should be able to review the function itself (falls under category Arrays). 1 Share this post Link to post Share on other sites
Luft08 27 Posted April 5, 2020 Thanks, I didn't know anything about "apply." I guess I still have a lot of learning ahead. Thanks again. Share this post Link to post Share on other sites