I want to be able to sort a two-dimensional array in order of both the first and second values. I already know you could do something like this:
arr = [[1,4],[3,5],[4,1],[3,2],[1,1]]
arr = arr.sort((a,b)=>{return a[1]-b[1]});
console.log(arr);
arr = arr.sort((a,b)=>{return a[0]-b[0]});
console.log(arr);
but, to simplify the runtime complexity for a coding problem, I want to combine them into one sort. Is there any way to do this?