把待排序的元素看成有序区和无序区,把无序区的元素一个个插入到有序区,并保证有序区仍然有序
//start是数组要排序的开始位置,length是要排序的长度
public static void sort(int [] datas,int start,int length)
{
int temp,j;
for(int i=from +1,i<from+length;i++)
{
temp=datas[i];
j=i-1;
while(j>=start)
{
if(datas[j]>temp)
{
data[j+1]=data[j];
j--;
}
else
{
break;
}
}
data[j]=temp;
}
}