Pergunta de entrevista da empresa eBay

One of the questions was Sorting a Diagonal Matrix.