From Beta Forum
Q: How can I sort all of the objects in a zone? Basically I’m looking to make a GameObject enemyArray of enemies in an OverlapSphere so I can then sort by distance. Anyone have any advice?
If you simply want to know which is the closest enemy to the player (or something else) you can do this.
You need a trigger zone set to detect Tag’s called distance which has zone size 0 and falloff size big enough to encompass your enemies to check the distance. The closest Tag called distance within the falloff will have the highest value.
On the enemies you have a Tag called Distance wired to a Gate gadget set to interrupt. Only one Gate gadget of the same name can be active at a time. As the tags move closer to the centre of the zone their value increases. The closest tag will have the highest value and its gate will become the active Gate
You can then have a microchip activated by the Gate with A Tag saying closest target or whatever logic you want the closest target to have.
Hope that helps get you started.