I had an array of strings and I made an array of numbers. And now I have arrays with two elements. I want to sort them from smallest to largest on both elements:
What is now:
const numArray = array.map(str => parseInt(str))
console.log(numArray)
[15, 5]
[3, 55]
[25, 5]
[3, 10]
[15, 25]
I want to get:
[3, 10]
[3, 55]
[15, 5]
[15, 25]
[25, 5]
How can this be achieved? I think I need to use .reduce()
or .sort()
, but don't know how to do it right. I would be glad for any help.