Pregunta de entrevista de Cargo Chief

sorting algorithm with an optimization