Skip to content

Latest commit

 

History

History
28 lines (18 loc) · 783 Bytes

README.md

File metadata and controls

28 lines (18 loc) · 783 Bytes

Matrix Generator

Write an function that takes 2 inputs:

  1. Number of rows
  2. Number of columns

Your function should do the following:

  1. Generate a multi-dimensional array with the specified number of rows and columns in the array populated with random numbers between 1 and 100.
  2. 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.
  3. Returns the sorted multi-dimensional array

Ex. generator(3, 3)

Output: [[1, 2 ,3], [4,5,6], [7,8,9]]

Stretch Goal

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]]