Tell us what’s happening:
Hello,
I’m working on that chalnge
And first question which I’m trying to solve how to sort 2D array by the sekond parametr arr[1]
by the first parameter no problem but how to do it by the second
How correctly to do it?
Your code so far
function updateInventory(arr1, arr2) {
arr2.sort(function(a, b){
//how to sort arry by the a[1] not by the a[0]???
return a[0] - b[0];
});
return arr2;
}
// Example inventory lists
var curInv = [
[21, "Bowling Ball"],
[2, "Dirty Sock"],
[1, "Hair Pin"],
[5, "Microphone"]
];
var newInv = [
[2, "Hair Pin"],
[15, "Half-Eaten Apple"],
[9, "Bowling Ball"],
[6, "Toothpaste"]
];
updateInventory(curInv, newInv);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36.