Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Sorting numbers

Preety WardhaPreety Wardha Member Posts: 1

I am trying to write a solution that will take input from the user and provide an output after sorting it. i,e. if anyone gives input as 654321 my program will return 123456. Below is the code I have written so far. But it is returning the same without sorting. What mistake I am doing here?

    static void Main(string[] args)
    {
        Console.WriteLine("Enter your number: ");
        int input = Convert.ToInt32(Console.ReadLine());

        int[] array = new[] {input};

        Array.Sort(array);

        foreach (var value in array)
        {
            Console.WriteLine(value);
        }
        Console.ReadKey();
    }
Tagged:

Comments

Sign In or Register to comment.