0

My values in a nested array like in the code and I want to sort it by the item name, but the array remain unchanged after the sort.

let arr1 = [ 
    [88, "Bowling Ball"],
    [2, "Dirty Sock"],
    [3, "Hair Pin"],
    [5, "Microphone"],
    [3, "Half-Eaten Apple"],
    [7, "Toothpaste"] ]
arr1.sort( (a, b) => a[1] - b[1]);
console.log(arr1);

0 Answers0