Select from an array based on values

I have an array of distances from the player to the enemy spawn point from which I am looking to pick out a value. Instead of choosing the closest value, I am looking to randomly select a distance based on its proximity, so if all the values were very similar, any could be chosen, where as if they were radically different, the chosen value would mostly be the closest value.
Thanks!

You necessarily need to define a ‘tolerance’ value which defines ‘proximity’ and then, you necessarily need to scan the whole array every time.

So you can solve this by a sorting algorithm, or by simply scanning the array every iteration, picking out the nearest value, then picking a random value, and seeing if such value is ‘close enough’ or if you need to fall back to the nearest value.