Wednesday 9 August 2017

Sorting the names in alphabatical order without sort() of C#.net

Hello Friends,
           Now I am going to describe  how to sorting the different names in alphabetical order without using sort function of c#.net.

Code of C#.net:
Simple create the console application and write this code:

class Program
    {
        static void Main(string[] args)
        {
            string[] arr = new string[] { "dotnet", "java", "oracle", "angularjs","nodejs" ,"sql","mvc"};
            int count;
            count = arr.Length - 1;
            for (int i = 0; i < count; i++)
            {
                for (int k = count; k > i; k--)
                {
                    if (((IComparable)arr[k - 1]).CompareTo(arr[k]) > 0)
                    {
                        dynamic name = arr[k - 1];
                        arr[k - 1] = arr[k];
                        arr[k] = name;
                   
                    }
                }
            }
            Console.WriteLine("your sorted name is:");
            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();
        }
    }


 
             I've explained how to sorting the different names in alphabetical order without using builtin function of c#.net.So after read please Comments and suggestions.

Thanks & Regard
Rabi

 

No comments:

Post a Comment