ACKO General Insurance interview question

sorting an array of strings with certain conditons