Amazon Interview Question

Sort an array considering time and space complexity