Write an function that takes 2 inputs:
- Number of rows
- Number of columns
Your function should do the following:
- Generate a multi-dimensional array with the specified number of rows and columns in the array populated with random numbers between 1 and 100.
- Sorts the array with natural numeric sorting. You will need to use/write/find a sort function as your argument to the JavaScript
Array.sort()
method for numbers to be sorted as numeric values. - Returns the sorted multi-dimensional array
Ex.
generator(3, 3)
Output: [[1, 2 ,3], [4,5,6], [7,8,9]]
Sort the inner arrays so that the first index is in order.
Example (before stretch):
[[2,3,4], [1,5,6], [7,8,9]]
Output (after stretch):
[[1,5,6], [2,3,4], [7,8,9]]