Sollicitatievraag bij Tripadvisor

a tipical leetcode question. Sort the array with some other conditions