Pine Labs interview question

DSA sorting problem without predefined