The endpoints are the (x₁, y₁) and (x₂, y₂) values. It does not matter which endpoint is first or second. You will get the same answer either way.
For example: assume we have two endpoints with coordinates (1, 3) and (4, 5)
Let (1,3) represent the first coordinate and (4,5) the second coordinate.
Then, M =

Now let's change the order so that (4, 5) represents the first coordinate and (1,3) represents the second coordinate.
Then, M =

Since we are adding two numbers and addition is commutative, then it doesn't matter which order the endpoints are in.