Amazon Interview Question

It was a specific sorting question about sorting certain chunks in an array. I had to write it out and then the efficiency of the program was asked as well.