Uber Interview Question

Given a matrix, Sort and reverse the outer loops