Tubi Interview Question

Simple sorting problem, clean the input.