public static void Main()
int[,] array = { { 1, 9, 0 }, { 9, 1, 5 }, { 1, 8, 7 }, { 2, 3, 0 } };
int[] temp = new int[array.GetLength(1) + 1];
for (int f = 0; f < array.GetLength(0); f++)
for (int c = 0; c < array.GetLength(1); c++)
temp[temp.GetLength(0) - 1] = f;
for (int ff = f + 1; ff < array.GetLength(0); ff++)
if (temp[0] < array[ff, 0] || (temp[0] == array[ff, 0] && temp[1] < array[ff, 1]))
for (int c = 0; c < array.GetLength(1); c++)
temp[temp.GetLength(0) - 1] = ff;
if (temp[0] > array[f, 0] || (temp[0] == array[f, 0] && temp[1] > array[f, 1]))
for (int c = 0; c < array.GetLength(1); c++)
array[temp[temp.GetLength(0) - 1], c] = array[f, c];