If you had tried everything you would have solved the problem. Learning to program isn't always easy, I know, but if you don't solve problems like this yourself you'll likely never be any good at it.
You said you learned about
bubble sort. Do you understand that
algorithm? Go through it again, trying to really understand it. Write it down more like a cooking recipe rather than computer code. Then, based only on the recipe, write it as code again. That way you'll make sure you really, truly understand it.
When it comes to the 2D array, the way that's probably easiest to understand is first converting it to a 1D array, sorting that and then converting it back. Here, look at this:
- 1 2 4 7
-
3 5 8 11
-
6 9 12 14
-
10 13 15 16
This displays the order in which the elements in a 4x4 2D array would be accessed. So, if you translate that 2D array to this 1D array
- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
it can easily be sorted. Then translate it back. It's very similar for the 5x5 array in that picture you posted.