Basically you set to swap your largest value in each column with an increasing x,y index.

Something like this perhaps.

Code:

const int xMax = 4;
const int yMax = 4;
int Array[xMax][yMax], diag, column, row;
for (diag = 0, column = 0; diag < xMax && diag < yMax
&& column < yMax; diag++, column++) {
for (row = 0; row < xMax; row++) {
if (Array[row][column] > Array[diag][diag])
swap(Array[row][column], Array[diag][diag]); // Function must be defined
}
}

That handles putting the highest values in the diagonal. Your second part of ordering that diagonal the way you do is slightly more difficult because it assumes that the succeeding row has at least one value less than the highest value in the last row.

Now I could set the if statement to be handle like this:

Code:

if (Array[row][column] > Array[diag][diag] && diag == 0)
swap(Array[row][column], Array[diag][diag]); // Function must be defined
else if (Array[row][column] > Array[diag][diag] && Array[row][column] < Array[diag-1][diag-1])
swap(Array[row][column], Array[diag][diag]); // Function must be defined

This will order it properly and when implemented in a simple program I wrote, I see that it does work correctly.

Output:

Code:

8 6 6 1
5 4 3 6
5 1 2 3
4 2 4 1
8 4 6 1
5 6 2 6
5 1 4 1
4 2 3 3

...but these were random numbers between 1 and 9, where there is a good chance of not running into the situation of succeeding row not having at least one value less than the highest value in the last row. If I were to say do random numbers between 1-50, I would run into the error more often.