Infosys interview question

How to get sorted collection?