Purushottam Rathore
How to Sort elements in Ascending Order of the array.
By Purushottam Rathore in ASP.NET on Apr 08 2011
  • Purushottam Rathore
    Apr, 2011 8

    static void Main(string[] args)
            {
                int[] num = new int[] { 20, 50, 10, 70, 40, 80, 30, 90, 60 };
                int t = 0;
                for (int i = 0; i < num.Length; i++)
                {
                    for (int j = i + 1; j < num.Length; j++)
                        if (num[i] > num[j])
                        {
                            t = num[i];
                            num[i] = num[j];
                            num[j] = t;
                        }
                }
                Console.WriteLine("Sorting elements in Ascending Order :\n");
                for (int i = 0; i < num.Length; i++)
                    Console.WriteLine(num[i]);
                Console.ReadLine();
            }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS