Essentially, you can calculate the Euclidean distance between your point ptand each tuple in your list. A function numpy.hypotcan do this, although it would be trivial to implement yourself if you want.
>>> from numpy import hypot
>>> l = [(1, 2), (3, 2), (1, 4)]
>>> pt = [8,7]
>>> sorted(l, key = lambda i: hypot(i[0]-pt[0], i[1]-pt[1]))
[(3, 2), (1, 4), (1, 2)]
source
share