public static int[] XiErSort(int[] num) { //设置步长 for (int step = num.Length/2; step > 0; step/=2) { //开始进行插入排序算法 for (int i = step; i < num.Length; i++) { //索引线后面一个值 int noNumSort = num[i]; //索引线-步长的值 int sortIndex = i - step; //满足条件,移动位置 while (sortIndex >= 0 && noNumSort < num[sortIndex]) { num[sortIndex+step] = num[sortIndex]; sortIndex -= step; } //插入最终数字 num[sortIndex + step] = noNumSort; } } return num.ToArray(); }