Explanation:
2 points, their distance and their x and y coordinate differences create a right-angled triangle with the distance being the Hypotenuse (the side opposite of the 90° angle).
and so, the distance formula is nothing else than Pythagoras :
distance² = (x coordinate difference)² + (y coordinate difference)²
distance² = (xh - xp)² + (yh - yp)² =
= (1 - -5)² + (-3 - 2)² =
= (1 + 5)² + (-5)² = 6² + 25 = 36+25 = 61
distance = sqrt(61)
as you can see, due to the squaring of the differences it is not important which point gets subtracted from which point. but it is important that once you decide a sequence for x, you use the same sequence also for y (or vice versa).