Skip to content

Commit c2f2d43

Browse files
committed
Clean up sort comparator
1 parent 8c5ea71 commit c2f2d43

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/geom/hull.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ d3.geom.hull = function(vertices) {
2727
fy = d3_functor(y),
2828
n = data.length;
2929

30-
for (i = 0, points = []; i < n; ++i) {
30+
for (i = 0, points = []; i < n; i++) {
3131
points.push([+fx.call(this, d = data[i], i), +fy.call(this, d, i), i]);
3232
}
3333

3434
// sort ascending by x-coord first, y-coord second
35-
points.sort(function(a, b) {
36-
return (a[0] < b[0] || (a[0] === b[0] && a[1] < b[1])) ? -1 : 1;
37-
});
35+
points.sort(function(a, b) { return (a[0] - b[0]|| a[1] - b[1]); });
3836

39-
// we flip bottommost points across y axis so we can use the upper hull routine on both
37+
// we flip bottommost points across y axis so we can use the upper hull routine on both
4038
var flipped_points = [];
4139
for (var i = 0; i < n; i++) flipped_points.push([points[i][0], -points[i][1]]);
4240

0 commit comments

Comments
 (0)