Skip to content

Commit 397d2e9

Browse files
author
James Wigger
committed
Added sorting fix for distance based results. Fixes #2
1 parent caab335 commit 397d2e9

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

addons/apps/jw_locator/admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
if ($CurrentUser->logged_in() && $CurrentUser->has_priv('jw_locator')) {
4-
$this->register_app('jw_locator', 'Locator', 1, 'Store / Location finder', '1.0.0');
4+
$this->register_app('jw_locator', 'Locator', 1, 'Store / Location finder', '1.0.1');
55
$this->require_version('jw_locator', 2.8);
66
$this->add_create_page('jw_locator', 'edit');
77

addons/apps/jw_locator/classes/JwLocator_Locations.class.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,13 @@ private function filtered_listing_template_callback($opts)
314314
unset($location['locationProcessingStatus']);
315315
}
316316

317+
// Fix distance ordering
318+
usort($rows, function($a, $b) {
319+
if(isset($a['markerDistance']) && isset($b['markerDistance'])) {
320+
return ($a['markerDistance'] < $b['markerDistance']) ? -1 : 1;
321+
}
322+
});
323+
317324
return $rows;
318325
};
319326
}

0 commit comments

Comments
 (0)