Skip to content

Commit

Permalink
Use https://github.com/chandon 's suggested usort fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BenOvermyer committed Sep 24, 2020
1 parent 1a1aa77 commit 94ea78f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Voronoi.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ public function compute($sites, $bbox)
$siteEvents = array_slice($sites, 0);
usort($siteEvents, function ($a, $b) {
$r = $b->y - $a->y;
if ($r) {
return $r;
if ($r > 0) {
return 1;
} elseif ($r < 0) {
return -1;
}
return $b->x - $a->x;
$s = $b->x - $a->x;
if ($s > 0) {
return 1;
} elseif ($s < 0) {
return -1;
}
return 0;
});

// process queue
Expand Down

0 comments on commit 94ea78f

Please sign in to comment.