Pregunta de entrevista de WHOOP

Sorting arrays based on filter