Challenging ranking within bubble

Hello, I want to order items in a certain way that it straight forward for programming but is challenging in native bubble. I have a list of clients my agents should meet. Every agent and every client have lists of places they can be at, saved as a geographic addresses.
I want to display a list to an agent which ranks the clients by their shortest distance from him/her. The complexity is that the shortest distance from an agent to a client comes from the pair agent place - client place, with the shortest distance among all the places combinations for the agent and the client.
Therefore for a given agent and a specific client I need to list all the pair combinations and take the minimal distance. Then repeat this for all the clients.

I would prefer not to use the database, and if possible do as much of the computation on the user’s client rather than on the server, but that’s not critical.