I was working on this logic to sort 2D arrays when I came across a problem. For some reason, the compiler would freeze up when it attempted to do so. I had this same exact problem with another code where it would do the exact thing.
So, I erased the code and began testing. I first checked a nested for loop, which was giving output. Using an if statement was working too. But the moment I used the second loop variable, it started freezing again. What is the issue here? Can somebody help me out?
it depends on how you want it sorted. if you can swap entire rows via a pointer, it saves some work for approaches where that is meaningful. If you want it strictly sorted where [0][0] < [0][1] ... -> that is where ( [N][M] < [N][M+1] or if last in a row [N+1][0]) then collapse to 1d is highly recommended. But it sounds like its not a sorting problem but a looping one... that was not demonstrated in the sample so its hard to help fix.