Goldman Sachs interview question

Strange sorting problem