Amazon interview question

sorting question with array and minimum time complexity