Hi, in relation to Inventory Update algorithm challenge, I was stuck on sorting for a long time with this:
arr1 = arr1.sort(function(a,b) {
return a[1] - b[1];
});
I did some research on the forum and came across Gaben14’s code and when I implemented it, I was able to get it working
arr1 = arr1.sort(function(a,b) {
if (a[1] < b[1]) return -1;
if (a[1] > b[1]) return 1;
return 0;
});
just wondering why my function is not able to sort “Half-Eaten Apple”, “Hair Pin” and “Microphone”? as when I used my code it will always sort like: “Hair Pin” "Microphone and “Half-Eaten Apple” Thank you in advance.