I have two matrices:
matrix1:
col1 col2
row1 5 4
row2 4 6
matrix2:
col1 col2
row1 48 50
row2 47 46
What I want is a new matrix or table:
Dim1 Dim2 rank
row2col1 4 47 1
row1col2 4 50 2
row1col1 5 48 3
row2col2 6 46 4
As you can see, I want to rank different combinations of rows and columns first based on dim1, and if there is a tie, by using dim2. The result matrix must be sorted using this rank. How can I achieve it? It is worth noting that matrix1 and 2 contains values for the dim1 and dim2 and have exactly the same column and row names.