Well suppose after the first sort, this is your input array
int arr[10]={1,2,3,7,8};
if the user enters 6, all you got to do is move the elements 8,7 one step behind. You see 8 is greater than 6 copy 8 to the 6th location. Same applies for 7. 3 is not greater than 6, so the loop ends there