Assuming you know how to sort a 1d array (otherwise look it up), this is fairly similar.
Instead of swapping two chars (when you use bubble sort or any other sorting algorithm based on swapping items), you swap the two complete rows.
So you get something like this (for bubble sort):
for char1 of each_last_row_char
for char2 of each_last_row_char_after_char1
if char2 < char2 then
swap rows of char1 and char 2
end
end
end
Swapping complete rows is not that difficult as well. You iterate over the amount of items in the rows (assuming they have the same amount of chars), and swap the items of both rows:
for index of row_items
tmp = row1[index]
row1[index] = row2[index]
row2[index] = tmp
end
Just like a regular swap implementation, but then for all items.
2
solved char multidimensional array sorting in java [closed]