Dielos 0 Posted April 8, 2010 How can I sort an array with markers according to their distance to a specific position? I couldn't find any function for it... Thanks Share this post Link to post Share on other sites
Jezuro 452 Posted April 8, 2010 Probably not the most elegant solution, should work fine though. _unsorted = [<your markers>]; _sorted = []; _pos = <your position>; { _closest = _unsorted select 0; {if ((markerPos _x distance _pos) < (markerPos _closest distance _pos)) then {_closest = _x}} forEach _unsorted; _sorted = _sorted + [_closest]; _unsorted = _unsorted - [_closest] } forEach _unsorted; _sorted Share this post Link to post Share on other sites
Dielos 0 Posted April 8, 2010 Thanks a lot, Jezuro! Simpler than I thought!!! Share this post Link to post Share on other sites
manzilla 1 Posted April 8, 2010 Whoa, I've been wondering about this for sometime. Thank you Jezuro! It's nice to see you around here. Share this post Link to post Share on other sites