Reading about the Mann-Whitney test for simple random and independent samples I encountered a small issue. According to the book "Introductory Statistics" by Weiss, the test statistic is obtained using
$M = \text{sum of the ranks for sample data from population 1}$
As usual, we use this test statistic to decide whether we reject the null hypothesis or not.
But this was a bit confusing because it seems arbitrary to choose a given sample as the first one. However, trying to clarifiy this, I found that there are other so-called test statistic $U$, and sometimes we are supposed to choose $\min(U_{1}, U_{2})$ or the opposite $\max(U_{1}, U_{2})$.
For example, in this tutorial, this statistic is used:
$U_{1} = R_{1} - \frac{n_{1}(n_{1} + 1)}{2}$
where $R_{1}$ is the sum of ranks in population $1$ as above.
It also adds:
Note that it doesn't matter which of the two samples is considered sample 1. The smaller value of U1 and U2 is the one used when consulting significance tables.
But this procedure doesn't seem to be used in Weiss' book.
Which one is the correct procedure? Maybe I'm just confusing different tests with similar names.