How to sort a range of int array in C#

3 Answers

0 votes
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] numbers =  { 9, 1, 0, 5, 2, 3, 8 };

            Array.Sort(numbers, 0, 4); 

            foreach (int value in numbers)
                Console.Write("{0, 2}", value);
        }
    }
}

/*
run:
   
 0 1 5 9 2 3 8
 
*/


answered Mar 6, 2015 by avibootz
0 votes
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] numbers =  { 9, 1, 0, 5, 2, 3, 8 };

            Array.Sort(numbers, 0, 2); 

            foreach (int value in numbers)
                Console.Write("{0, 2}", value);


        }
    }
}

/*
run:
   
  1 9 0 5 2 3 8
 
*/


answered Mar 6, 2015 by avibootz
0 votes
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] numbers =  { 9, 1, 0, 5, 2, 3, 8 };

            Array.Sort(numbers, 2, 3); 

            foreach (int value in numbers)
                Console.Write("{0, 2}", value);


        }
    }
}

/*
run:
   
  9 1 0 2 5 3 8
 
*/


answered Mar 6, 2015 by avibootz

Related questions

1 answer 347 views
1 answer 180 views
180 views asked Mar 6, 2015 by avibootz
2 answers 226 views
1 answer 202 views
...