vendredi 9 décembre 2022

I need to sort a printed array of numbers by size. C# [duplicate]

So in my homework assignment we are supposed to: Make an array with ten integers, sort them to an order of size, and print them.

A former answer told me how to print the array, now I just have to sort it.

I've managed to make and array that generates the numbers, prints them in the console, but I'm having trouble on having them sorted into an order of size.

Here is what I've got done, and now I'm stuck here:

internal class Program
    {
        private static void RandomNumbers()
        {
            int Min = 0;
            int Max = 100;

            int[] ints = new int[10];
            Random randomNum = new Random();

            for (int i = 0; i < ints.Length; i++)
            {
                ints[i] = randomNum.Next(Min, Max);
            }

            for (int i = 0; i < ints.Length; i++)
            {
                Console.WriteLine($"{i}: {ints[i]}");
            }
        }

        static void Main(string[] args)
        {
            RandomNumbers();
        }
    }

I haven't found a way to sort the randomized numbers by size. It's the last part of the assignment.




Aucun commentaire:

Enregistrer un commentaire