Allow to calculate the distance using a second set of coordinates

I need to find all places near a specific location, but sorted by a second location, and showing the distance from such second location. I'm adding a parameter, select_location, which allows to use that second location to calculate distance, and hence, to sort by such distance.