插入排序

public class InsertionSorter   
{   
    public void Sort(int[] arr)   
    {   
        for (int i = 1; i < arr.Length; i++)   
        {   
            int t = arr[i];   
            int j = i;   
            while ((j > 0) && (arr[j - 1] > t))   
            {   
                arr[j] = arr[j - 1];//交换顺序   
                --j;   
            }   
            arr[j] = t;   
        }   
    }    
}

原文地址:https://www.cnblogs.com/qiuh/p/2782411.html