I have so called 2D array called myarr with dozen rows and 2 column. Its contents is as follows:
myarr[0][0]='John'
myarr[0][1]=48
myarr[1][0]='Ann'
myarr[1][1]=36
myarr[2][0]='Sean'
myarr[2][1]=18
...
And I would like to sort it by second column first descending, then by first column ascending, like this one:
John 48
Ann 36
Bob 36
Carl 36
Sean 18
Dean 17 ..
By using JavaScript and I tried something like this:
myarr.sort(function(a, b){
a = a[1]+a[0];
b = b[1]+b[0];
return a == b ? 0 : (a > b ? 1 : -1)
})
But this way sort by column 2 asc (0 - 85) then by column 1 asc (A - Z). Where I made error? Thank you.