The above answer, despite being a little short, if answered, should solve your problem. Basically you need some way or knowing how far away each location is from each other location and the some way of searching though these distances to find the smallest that has the stock....
At nice like experiment in Geo Spatial Data (think that is the right phrase).