Check The Programming Section
We can apply bubble sort between the items of a row. The sort function will be called equal to the number of rows in a 2-d array. Consider the below input.
A square matrix of size 3 X 3 is given as input and there after 9 items are given as input to populate the 2-d array. The sort function is called inside a loop and for loop written at line 42 passed each row one after another. The loop index variable i is pointing to a row of the matrix and the variable col passed all the columns for each iteration.