I used filter () to filter an array
let mDistance = markerXYarray.filter(function(markerTouch) {
const distance = (start.lng - markerTouch.lon) * (start.lng - markerTouch.lon) + (start.lat - markerTouch.lat) * (start.lat - markerTouch.lat);
return distance < 0.00001;
});
console.log(mDistance);
mDistance.sort(function(first, next) {
const firstDis = first.lon * first.lon + first.lat * first.lat;
const nextDis = next.lon * next.lon + next.lat * next.lat;
return firstDis - nextDis;
});
console.log(mDistance);
But the results of the two prints are the same