Perhaps we have an array of arrays such as this:
["a", "11.36"]
["b", "12.13"]
["c", "11.00"]
Is there a simple function to be able to sort them based on the 2nd index?
Perhaps we have an array of arrays such as this:
["a", "11.36"]
["b", "12.13"]
["c", "11.00"]
Is there a simple function to be able to sort them based on the 2nd index?
With use of Array.prototype.sort() and Destructuring assignment it would look like this
const a = [
["a", "11.36"],
["b", "12.13"],
["c", "11.00"]
];
a.sort(([,a], [,b]) => a - b)
console.log(a)