If the title isn't clear, let me give you an example:
I've got an array sorted by first column - date and I need to sort it once again in order of appearance of value in column name
data[100][4]
date | name | text | type
-----+------+------+------
2222 | z | wwww | 2
2221 | z | qqqq | 1
2220 | c | dasa | 2
2219 | b | dsad | 1
2218 | z | dfsa | 2
2217 | c | dasd | 1
And here's the sorted array:
order[100][4]
date | name | text | type
-----+------+------+------
2222 | z | wwww | 2
2221 | z | qqqq | 1
2218 | z | dfsa | 2
2220 | c | dasa | 2
2217 | c | dasd | 1
2219 | b | dsad | 1
I thought of merging those data into one string and inserting some symbol between columns to retrieve it back in the future, adding to ArrayList and then retrieving by name. I've added data[i][1] to HashMap to determine number of unique values, so I could know the number of loop cycles. And there comes the order of name values which puzzles me because HashMap doesn't maintain order.
Does anyone know how it can be sorted without all that trouble?