Question: Code the following using python: (1) Popualte the 2-d list with random numbers (2) Write a function to sort two dimesional 3*n matrix (3 rows,

Code the following using python:

(1) Popualte the 2-d list with random numbers

(2) Write a function to sort two dimesional 3*n matrix (3 rows, and columns)

(3) Sort the matrix based on 1st raw-> 2nd raw-> 3rd raw, and then print out the numbers

You need to show & explain how your code works.

===============

An example test of your code: output:

Initial zero matrix with 3 rolls

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

before sorting

2 1 5 5 2 2 5 4 1 4 4 0 2 0 5 2 1 2 4 3 0 1 0 0 3 1 0 3 4 3 3 0 3 0 1 5 1 3 4 2 1 4 1 4 3 2 3 4 4 4 3 4 5 2 0 2 4 0 4 3

1 0 3 0 5 5 1 2 1 4 4 5 3 4 0 0 0 3 1 0 2 1 5 4 1 1 0 3 4 3 4 3 1 5 5 5 4 2 3 4 1 4 0 2 0 4 5 0 3 1 5 4 1 2 2 0 1 0 3 0

0 3 0 1 1 5 4 3 3 4 0 1 0 4 3 5 0 5 4 5 4 1 2 3 1 1 5 3 1 4 4 4 5 4 0 2 3 1 0 1 0 4 1 4 1 2 3 3 0 2 2 0 0 5 0 3 2 3 1 2

After sorting

0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5

0 0 2 2 3 4 4 5 5 5 0 0 0 1 1 1 1 4 5 0 0 1 2 3 3 4 4 5 5 0 0 0 1 1 2 3 3 4 5 5 0 1 1 1 2 2 3 3 3 4 4 4 4 4 0 0 1 1 3 5

3 5 0 4 4 3 4 1 2 4 0 1 3 0 1 1 3 3 0 3 5 0 5 0 5 1 2 1 5 1 2 5 1 5 1 3 4 4 2 3 3 2 2 4 3 4 0 0 1 0 0 1 4 4 1 3 0 4 0 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!