If the rule is supposed to be smallest to largest, your example is flawed.
e.g. you have 2 and 7 in the second row. Shouldn't they be in the first row?
You have a couple of problems with your algorithim.
1) In lines 8,10 and 11, you refer to arr[c][r+1]. That's going to be a problem when is r equal to N-1. You're going to be referencing a row outside the array.
2) You're only making a single pass through the array. You're not going to catch multiple transpositions. Consider 3 2 1. You first compare and swap 3 and 2 resulting in 2 3 1. You then compare and swap 3 and 1, resulting in 2 1 3. You never go back to reconsider 2 and 1 which are still out of order.
not from smallest to largest sorry
i meant to sort them diagonally
do you have any idea how?
because i tried different type of methods none of them worked :/