Sorting integer array
Here are some links to sorting techniques:
bubble sort ,
insertion sort, merge sortWhat you're doing in your code isn't efficient. In the worst case scenario where the array is totally unsorted it'll take quite sometime to sort it the way you're doing it.