Pergunta de entrevista da empresa RBC

A simple coding question having to do with sorting arrays