All problems
Sort Each Row
Problem
Sort the entries of every row of matrix A in ascending order.
Return a new matrix with the same shape.
Hint
Each row is reordered independently of the others.
Test cases
case 1
in: [[[3,1,2],[6,4,5]]]
expected: [[1,2,3],[4,5,6]]
case 2
in: [[[-1,-3,-2]]]
expected: [[-3,-2,-1]]
case 3
in: [[[1,1,1]]]
expected: [[1,1,1]]
case 4
in: [[[2],[1]]]
expected: [[2],[1]]
Starter codePython
def sort_rows(A):
# Your code here
pass4 test cases · run your code against them in the editor