Datadog interview question

Algorithm to sort according to a condition