Nagarro interview question

related to string sorting