Pergunta de entrevista da empresa Apple

sorting algorithm for complicated queue