Pergunta de entrevista da empresa Amazon

Sort an array considering time and space complexity