Sort descending Array in C#

In this article I will explain that how to create Sort descending in Array.
  • 4077

Program that uses Array.Sort LINQ descending [C#]

We see how you can call the static Array.Sort method and use it to sort a string array in place. The result is an alphabetical sort. LINQ here is used with a query expression that is an enumeration of the original strings ordered from Z to A.

namespace demo_arraylist

{

    class Program

    {

        static void Main(string[] args)

        {

            //Program that uses Array.Sort Character Ascending Order

            string[] a = new string[]

               {

                     "Manish",

                "Raju",

                "Swati",

                "Papa",

                "Manisha",

                "Zaineb",

                "Ajay",

                "Rajiv",

               };

            var sort = from s in a

                       orderby s descending

                       select s;

 

            foreach (string c in sort)

            {

                Console.WriteLine(c);

            }

            Console.ReadKey();

        }

    }

}

Output

sort_desce_array.jpg

Ask Your Question 

Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.