Tubi interview question

Simple sorting problem, clean the input.