Trying a little experiment with PHP's SPLHeap, but puzzled by the fact that iterating over the heap seems to be removing each entry as I access it.
The code
class ExtendedSPLHeap extends \SPLHeap {
protected function compare($a, $b) {
if ($a->latitude == $b->latitude) {
return 0;