[BangPypers] I need some help/guidance

Abdul Muneer abdulmuneer at gmail.com
Tue Apr 16 10:02:26 CEST 2013


Basically you can sort any list by passing a key as follows:

base_location = (x,y)
locations = [(x1, y1), (x2, y2), ....(xn, yn)]

def distance_between(geocordinate1, geo_cordinate2):
    ''' write your code here to return the distance between two cordinates
      you can use google maps api for this.
*locations.sort(key = lambda x: distance_between(x, base_location))* #sorts
the list in-place

Abdul Muneer

Follow me on Twitter: @abdulmuneer <http://twitter.com/#%21/abdulmuneer>

On Tue, Apr 16, 2013 at 12:17 PM, Smrutilekha Swain
<smrutilekha at gmail.com>wrote:

> i am writing a program using PyQt4. i have created a table containg name of
> the instruments, locations, its latitudes, longitude and altitude.
> there may be two instruments and its locations are same but different
> latitude and longitude with mild difference.
> so now i want to sort the table by latitude or longitude whose have least
> difference...
> can u plz give me sume hints or guidance how to do.....
> thanzzzzzzz in advance..........waiting for ur reply............
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers

More information about the BangPypers mailing list