2
* @param {number[][]} points6
var kClosest = function (points, k) {8
let hashMap = new Map();9
for (let i = 0; i < points.length; i++) {10
//store the distance and the index of the points in a map11
const dis = calcDis(points[i]);14
//sort the map by its distance to the origin15
const hashMapNew = new Map([...hashMap].sort((a, b) => a[1] - b[1]));16
//use the index sorted by distance to get the result18
for (const x of hashMapNew.keys()) {27
return Math.sqrt(Math.pow(b[0], 2) + Math.pow(b[1], 2));