I need help at sorting multidimensional array in ascending order.
So if input are:
2 5 6 1 4
5 9 2 1 3
7 4 2 4 5
9 2 5 8 5
I need the output:
1 1 2 2 2
2 3 4 4 4
5 5 5 5 5
6 7 8 9 9
And this is my mini version of the application, I stuck and don't even know how to search that, I have no idea how to push it, so I hope to seek help.
And This is my code:
static void Main(string[] args)
{
int row = 4;
int column = 5;
int[,] mas = new int[row, column];
InitMas(mas);
PrintMas(mas);
}
static void InitMas(int[,] arr)
{
Random rn = new Random();
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr.GetLength(1); j++)
{
arr[i, j] = rn.Next(10, 100);
}
}
}
static void PrintMas(int[,] arr)
{
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr.GetLength(1); j++)
{
Console.Write(arr[i, j] + " | ");
}
Console.WriteLine();
}
}