Amazon interview question

Sort an array considering time and space complexity