Pergunta de entrevista da empresa Amazon

Oa question regarding reading 2d array and sorting it.