'Most efficient way of finding information to transport to client

I have a simple game where I have dictionary with keys as a user id and values as an array of two values: X and Y of player. I need to send to each player data packet(threw node.js - socket.io) containing all nearby players, so client will render them on screen. How could i do it by the most efficient way?

If you know really better way of doing it, i can rewrite dictionary, it isn't a big problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source