My code for the input given by me is not showing correct sorted list

int temp=arr[min];
arr[min]=arr[counter];
arr[counter]=temp;

This swapping needs to be done outside the 2nd for-loop. Make that change and then your code will sort correctly.