Pregunta de entrevista de Weedmaps

General sorting algorithm with a simple caveat. Do not remember the specific question at this time.