How to optimise this code?

https://www.codechef.com/viewsolution/35737656
It is showing run time error please help.
question is TSORT

i believe you are implimenting insertion sort?
worst case time complexy of insertion sort in O ( n^2 ). so it was obvious that why you got TLE.

you would need something like merge sort for best result.