The k points nearest the origin
Given points, a list of [x, y] pairs with integer coordinates, and an integer k, return the k points nearest the origin (0, 0) by straight-line distance, in any order. A point that appears twice counts twice. k is between 0 and the number of points, and the tests never tie two different points for the last place, so the answer is unique.
Aim for O(n log k): don't sort every point when k is small.
Examples
nearest_points([[1,3],[-2,2],[5,-1]], 1)→[[-2,2]]nearest_points([[3,3],[5,-1],[-2,4],[0,1]], 2)→[[0,1],[3,3]]nearest_points([[2,0],[0,-2],[4,4]], 2)→[[2,0],[0,-2]]