I am a newbie to C programming and was trying to prepare some sorting programs. I made the program of linear/ normal Sorting.
Now I want to make a program to sort 2D array.
i.e. If the matrix is
4 6 1
3 2 9
5 7 8
Then the result should be
1 2 3
4 5 6
7 8 9
Since you want your 2D array to be sorted row-wise, which happens to be the order in which multidimensional arrays are stored in C, you could pretend it is a 1D array and sort it that way.
Assuming you have a function
void sort(int[], int size);that takes a pointer to the first element of a 1D array and its size, you could doNaturally, this only works for true 2D arrays, not for arrays of pointers, which is how dynamically allocated 2D arrays are often implemented in C.