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:
[1, 2, 3, 4, 5]
[40,50,20,30,10]
I know how to do that with bubble sort, but I need some faster algorithm, e.g. quicksort.
Here is my bubble sort code
for (int i = 0; i < length-1; i++) {
for (int j = 0; j < length-i-1; j++) {
if (array[0][j] > array[0][j+1]) {
for (int k = 0; k < 2; k++) {
int tmp = array[k][j];
array[k][j] = array[k][j+1];
array[k][j+1]=tmp;
}
}
}
}