Pregunta de entrevista de Datadog

Algorithm to sort according to a condition