Hello,
I have a 2D array of ints that I need to sort independently by columns in descending order.
For example right now I have:
0 1 2 3 4
5 19 7 33 9
10 11 24 13 14
15 16 43 30 19
20 21 22 23 24
and i want it to have the largest number in each column on top and and descend from there, but I don't know how to write the code.
any ideas would be great. Thanks!
|
Pro contributor
|
![]() |
| 20Feb2011,03:28 | #2 |
|
if you had an 1d array what would you have as code?
|
|
Newbie Member
|
|
| 20Feb2011,08:26 | #3 |
|
I'd use
Code:
Arrays.sort(<array name>); |
|
Pro contributor
|
![]() |
| 21Feb2011,02:53 | #4 |
|
see this
http://www.roseindia.net/java/beginn...bbleSort.shtml for 1d array. hint:a 2d array MxN is ---->N 1d arrays Mx1 or you can do it like this http://publicmind.in/blog/sorting-2d-array-java/ Last edited by virxen; 21Feb2011 at 02:59.. |

