Sorting integer array Please check this program that sorts an integer array.  It doesn't look very efficient.  Please tell me how to correct this.

int temp;
for(int i=0;i&lt;nums.length-1;i++)
{
    if(nums[i]&gt;nums[i+1])// if this is true, swap the value
    {
        temp=nums[i];
        nums[i]=nums[i+1];
        nums[i+1]=temp;
        i=-1;//If there is swap happen, loop will start again from 0th element
    }
}
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.