# a little trick: finding the closest

Let’s say you have a bunch of points and you need to either order them by distance to some fixed point, or find the closest.

Euclidean distance is easy, right?

$\sqrt{{(x_j - x_i)}^2 + {(y_j - y_i)}^2}$

Hold it!  Why are you taking the square root?

If all you need  is to rank by distance,  then ranking by distance squared will give you the same result. Forget getting the square root.

Obviously, this makes no discernible difference for onesie-twosie calculations. But can make a big difference if you have lots to do.

Jus’ sayin’.