How to Sort Numbers with If Statements (Java)

Since a complete answer was already posted, here is another algorithm. By using a sorting network, this can be done with 5 if / swap statements. This is a c code example for descending sort of 4 numbers:

void sortnet4(int a[4])     /* four input sorting network */
{
int t;
    if (a[0] < a[2]) { t = a[0]; a[0] = a[2]; a[2] = t; }
    if (a[1] < a[3]) { t = a[1]; a[1] = a[3]; a[3] = t; }
    if (a[0] < a[1]) { t = a[0]; a[0] = a[1]; a[1] = t; }
    if (a[2] < a[3]) { t = a[2]; a[2] = a[3]; a[3] = t; }
    if (a[1] < a[2]) { t = a[1]; a[1] = a[2]; a[2] = t; }
}

This example shows an ascending order sort of 10 numbers:

void sortnet10(int a[10])   /* ten input sorting network, 29 if/swaps */
{
    int t;
    if (a[0] > a[5]) { t = a[0]; a[0] = a[5]; a[5] = t; }
    if (a[1] > a[6]) { t = a[1]; a[1] = a[6]; a[6] = t; }
    if (a[2] > a[7]) { t = a[2]; a[2] = a[7]; a[7] = t; }
    if (a[3] > a[8]) { t = a[3]; a[3] = a[8]; a[8] = t; }
    if (a[4] > a[9]) { t = a[4]; a[4] = a[9]; a[9] = t; }
    if (a[0] > a[3]) { t = a[0]; a[0] = a[3]; a[3] = t; }
    if (a[5] > a[8]) { t = a[5]; a[5] = a[8]; a[8] = t; }
    if (a[1] > a[4]) { t = a[1]; a[1] = a[4]; a[4] = t; }
    if (a[6] > a[9]) { t = a[6]; a[6] = a[9]; a[9] = t; }
    if (a[0] > a[2]) { t = a[0]; a[0] = a[2]; a[2] = t; }
    if (a[3] > a[6]) { t = a[3]; a[3] = a[6]; a[6] = t; }
    if (a[7] > a[9]) { t = a[7]; a[7] = a[9]; a[9] = t; }
    if (a[0] > a[1]) { t = a[0]; a[0] = a[1]; a[1] = t; }
    if (a[2] > a[4]) { t = a[2]; a[2] = a[4]; a[4] = t; }
    if (a[5] > a[7]) { t = a[5]; a[5] = a[7]; a[7] = t; }
    if (a[8] > a[9]) { t = a[8]; a[8] = a[9]; a[9] = t; }
    if (a[1] > a[2]) { t = a[1]; a[1] = a[2]; a[2] = t; }
    if (a[3] > a[5]) { t = a[3]; a[3] = a[5]; a[5] = t; }
    if (a[4] > a[6]) { t = a[4]; a[4] = a[6]; a[6] = t; }
    if (a[7] > a[8]) { t = a[7]; a[7] = a[8]; a[8] = t; }
    if (a[1] > a[3]) { t = a[1]; a[1] = a[3]; a[3] = t; }
    if (a[4] > a[7]) { t = a[4]; a[4] = a[7]; a[7] = t; }
    if (a[2] > a[5]) { t = a[2]; a[2] = a[5]; a[5] = t; }
    if (a[6] > a[8]) { t = a[6]; a[6] = a[8]; a[8] = t; }
    if (a[2] > a[3]) { t = a[2]; a[2] = a[3]; a[3] = t; }
    if (a[4] > a[5]) { t = a[4]; a[4] = a[5]; a[5] = t; }
    if (a[6] > a[7]) { t = a[6]; a[6] = a[7]; a[7] = t; }
    if (a[3] > a[4]) { t = a[3]; a[3] = a[4]; a[4] = t; }
    if (a[5] > a[6]) { t = a[5]; a[5] = a[6]; a[6] = t; }
}