title: Sort data by closest geolocation with filtering
body: <p>I am trying to locate correct building where someone is using my application in. Right now i have managed to do a pretty bad filtering and i need to improve it.</p>
  
  <p>What my goal is with filtering to return the closest building to the person using the application, so filter it as good as possible without creating errors when moving around in the same building.</p>
  
  <p>My fetch returns an api JSON array that looks like this:</p>
  
  <pre><code>{
  "data": [
  {
    "id": 1,
    "city": "CITY",
    "building_name": "Building 1",
    "building_address": "Address 123",
    "latitude":  "57.7052809",
    "longitude": "16.9367817"
  },
  {
    "id": 2,
    "city": "CITY",
    "building_name": "Building 2",
    "building_address": "Address 456",
    "latitude":  "35.7054509",
    "longitude": "16.9366141"
  }
  ],
  }
  </code></pre>
  
  <p>This is my code</p>
  
  <pre><code>fetch('http://localhost:8888/api/buildings')
  .then(response =&gt; response.json())
  .then(data =&gt; {
  
    userCoordinates = {
      latitude:  35.7053509,
      longitude: 16.9362301
    }
  
  
    const returnedBuilding = Object.entries(data.data).map(([inst, key]) =&gt; key)
    .filter(thing =&gt; (thing.latitude &gt; userCoordinates.latitude - .5 &amp;&amp;
       thing.latitude &lt; userCoordinates.latitude + .5) &amp;&amp;
        (thing.longitude &gt; userCoordinates.longitude -.5 &amp;&amp;
         thing.longitude &lt; userCoordinates.longitude + .5));
  
         console.log(returnedBuilding);
  
  })
  </code></pre>