I'm trying to write a performance orientated array lookup that will return the closest longitude and latitude relative to the users current location.

One issue is that I have 5000 locations in my array and am needing to loop through all results returning the closest in as fast a time as possible, I am also having issues with the filter as currently it is returning the wrong results (which I believe is due to the lookup only looking for the closest negative to current)

Here is my code:

```
    if(has('geolocation')){

            navigator.geolocation.getCurrentPosition((position) => {

                // Example result from getCurrentPosition (this is my exact location)
                //
                // position.coords = {
                //  latitude: 51.4523,
                //  longitude: -0.9724
                // }

                // This is the nearest location
                //
                // location = {
                //  latitude: 51.457495699999996,
                //  longitude: -0.973083
                // }

                // This is the location my filter keeps returning
                //
                // location = {
                //  latitude: "50.6931",
                //  longitude: "-4.0094",
                //  name: "Yes Tor"
                // }

                let closest = this.locations.filter((location) => {
                    console.log(location, position.coords);
                    return location.latitude <= position.coords.latitude && location.longitude <= position.coords.longitude;
                }).pop();

                console.log(closest); //Is incorrect

            });

        }

```

I have commented my current results, my question is if there is a faster way of doing this and if there is a way to get closest for both negative and positive from current.

If anyone needs it here is an example of the array structure (length is 5968)

```
            let this.locations = [
                {
                    elevation: "936.0",
                    id: "350001",
                    latitude: "56.8716",
                    longitude: "-4.1969",
                    name: "A' Bhuidheanach Bheag",
                    region: "ta",
                    unitaryAuthArea: "Perth and Kinross"
                },
                {
                    elevation: "999.0",
                    id: "350024",
                    latitude: "57.6926",
                    longitude: "-5.1328",
                    name: "A'Chailleach (Fannaich Region)",
                    region: "he",
                    unitaryAuthArea: "Highland"
                }
            ]

```