I have an array with this structure:
myArray = [ [<number>, [<string>] ], [<number>, [<string>] ], ... ];
I'd like to sort the array according to the ints. Unfortunately, when I call .sort() on myArray it returns me an array sorted according to the strings. How could I solve this?
Try this
myArray.sort(function(a,b) {return a[0]-b[0]})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With