So say I have an array of objects that includes details about individuals. The array is as follows:
volunteers = [{name:"john",age:"32",origin:{lat:(some number),lng:(some number)},{name:"tony",age:"34",origin:{lat:(some number),lng:(some number)},{name:"timothy",age:"27",origin:{lat:(some number),lng:(some number)},{name:"pat",age:"35",origin:{lat:(some number),lng:(some number)}
These individuals are volunteer firefighters. I'd like to sort this array by their distance to my fire. The fire also has coordinates fireCoordinates: {lat:(some number),lng:(some number)}
How do I sort my volunteers array by their distance to the fire?
Edit: I've tried different variations of the Haversine formula so far but they haven't been the cleanest solutions since a relatively large amount of code is required and a tedious loop. Also, I'm not necessarily looking for a positive answer, maybe it can't be done. I'd love to understand why either ways.
Thanks