• Top Posts

    C# program to Generic Insertion Sort


     using System;  
     using System.Collections.Generic;  
     using System.Linq;  
     using System.Text;  
     using System.Threading.Tasks;  
     using System.Security;  
     using System.Runtime.Versioning;  
     using System.Runtime.CompilerServices;  
     public class Main  
     {  
       private static void InsertionSort(T[] keys, int lo, int hi, IComparer<T> comparer)  
       {//from www . j a v a 2 s .c om  
         for (int index1 = lo; index1 < hi; ++index1)  
         {  
           int index2 = index1;  
           T x;  
           for (x = keys[index1 + 1]; index2 >= lo && comparer.Compare(x, keys[index2]) < 0; --index2)  
             keys[index2 + 1] = keys[index2];  
           keys[index2 + 1] = x;  
         }  
       }  
     }  
    

    No comments

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728