def get_k_closest_points(point, data, k, distance_metric):
    """Given a test point, a list of points (the data), an int 0 < k <= len(data),
    and a distance metric (a function), returns a list containing the k points
    from the data that are closest to the test point, according to the distance
    metric.  Breaks ties lexicographically by coordinates."""
    distances = {}
    for d in data:
        distances[str(d)] = distance_metric(point,d)
    return sorted(data,key = lambda data:(distances[str(data)], data.coords))[:k]