I need help with sorting 2D array. I\'ve got array with two rows
[5, 3, 4, 1, 2]
[10,20,30,40,50]
and I need to sort it to look like this:
transpose the 2D array java multi-dimensional array transposing
use Arrays.sort(T[] a, Comparator super T> c)
where the comparator compares on index 0 of each row
transpose the result again:
e.g.
from: [5,3,4,1,2] [10,20,30,40,50]
obtain [5, 10] [3, 20] [4, 30] [1, 40] [2, 50]
then sort them to [1, 40] [2, 50] [3, 20] [4, 30] [5, 10]
then transpose again to: [1,2,3,4,5] [40,50,20,30,10]
or implement quicksort by yourself.