CSharp examples for Data Structure Algorithm:Sort
Insert Sort int Array
using System.Linq; using System.Collections.Generic; using System;/*w ww . jav a 2 s . c o m*/ public class Main{ static public void Insert_Sort(int[] array) { int cnt = array.Length; if (cnt == 1 || cnt == 0) return; for (int ii = 1; ii < cnt; ++ii) { var elem = array[ii]; int jj; for (jj = ii - 1; jj >= 0; --jj) { if (array[jj] < elem) break; array[jj + 1] = array[jj]; } array[jj + 1] = elem; } } }