DigiValet interview question

sorting problem