Asana can use coordinate-like representations to identify tasks nearest to a selected workspace location. Given a list of 2D integer points and a reference point, return the k closest points using squared Euclidean distance.
Implement k_closest_points(points, reference, k). A point is represented as [x, y], and reference is also represented as [x, y]. The distance is (x1 - x2)² + (y1 - y2), so no square root is needed. Return exactly k points, sorted by increasing distance. If distances tie, sort by increasing x, then increasing y.
Use an algorithm that avoids sorting all points when k is much smaller than the number of points.
def k_closest_points(points, reference, k):