I need to sort a list of lat/long values based on their distance from the user's current lat/long. I also need to display the distance in Miles for each entry.
I found this answer that is close but returns the nearest lat/long entry rather than a list. Also, I don't understand the distance unit used to be able to convert to Miles.
In short, I need a method where...
- You provide a current Lat/Long pair and a list of Lat/Long pairs
- Return a sorted list of Lat/Long pairs with distance in Miles
class Location
{
double Lat { get; set; }
double Long { get; set; }
double Distance { get; set; }
}
public List<Location> SortLocations(Location current, List<Location> locations)
{
// ???
}