The following multi-array is sorted randomly:
let arr = [[3, "C"], [2, "B"], [3, "Q"], [1, "A"], [2, "P"], [1, "O"]];
The intention is to sort it as:
arr = [[1, "O"], [1, "A"], [2, "P"], [2, "B"], [3, "Q"], [3, "C"]];
viewed as a table:
/*
col 1 | col 2 col 1 | col 2
3 | C 1 | O ˄
2 | B | 1 | A ¦
------------- | -------------
3 | Q =˃ | 2 | P ˄
1 | A | 2 | B ¦
------------- | -------------
2 | P ˅ 3 | Q ˄
1 | O 3 | C ¦
*/
in another perspective I want to achieve what in a SQL query will be something like:
SELECT * FROM table
ORDER BY column1 ASC, column2 DESC
how to do that? or is there a better method instead of using Arrays? thanks!