Infosys interview question

Prepare a logic of sorting