In my possession is the following 2D array:
[["fox", "100"], ["the", "1"], ["quick", "50"]]
The task at hand is to keep only the first element of the array, but have it sorted based on the second value.
The expected result should be: the,quick,fox
A loop has been implemented that iterates over the first elements successfully, however arranging them in order of the second value remains a challenge:
for (var i = 0; i < inputArr.length; i++) {
x1 += inputArr[i][0];
if(i != inputArr.length - 1){
x1 = x1 + ",";
}
}
Write(x1); //outputs -> fox,the,quick