Meta interview question

array manipulation question with sorting