If you mean straight line distance and if the locations are reasonably 
close and/or reasonably well distributed then just do a straightforward 
trig calculation.

If you want more accuracy use a great circle distance calculation (just 
Google it).   Assuming you just need a ranking rather than accurate 
distance I suspect this would be overkill in most real-world situations.

If you had thousands of locations to sort rather than just 200 I would do 
the simple trig calc, then sort into distance order and then walk the list 
to see if the distance/separation of adjacent location pairs was within a 
threshold and do the the gc calc to determine the closest.



On Monday, December 31, 2012 7:32:18 AM UTC-5, Nelson André wrote:
>
> Hello all,
>
> I have a JSON list that I retrive from one website I have that gives me 
> the following fields:
>
>
>    - Name
>    - Latitude
>    - Longitude
>
> This list has around 200 items.
>
> I want to order the list by distance to my current location, closer 
> locations on top.
>
> How may I do this calculation and ordering?
>
> Many Thanks
>
> Nelson
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to