使用直接排序法对一维数组进行排序

实现效果:

  

实现原理:

  

实现代码:

        public int[] sory(int[] intArray)
        {
            for (int i = 0; i < intArray.Length;i++ )
            {
                int j = i;
                int temp = intArray[i];
                while((j>0)&&temp>(intArray[j-1])){
                    intArray[j] = intArray[j - 1];
                    j--;
                }
                intArray[j] = temp;
            }
            return intArray;
        }

  

原文地址:https://www.cnblogs.com/feiyucha/p/10063562.html