Meta Interview Question

array manipulation question with sorting