'Calculating the closest store next to my location based on Longitude and Latitude

I want to create an algorithm that takes an array of grocery stores with their location (long and lat) and based on my current location calculates which store is closest to me.

Do you have any idea what is the most optimal way to create such an algorithm? Thank you in advance!



Sources

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

Source: Stack Overflow

Solution Source