sort 5 9 1 8 into order in csharp

To sort an array of numbers in C#, you can use the built-in Array.Sort() method. Here's an example code snippet that sorts the numbers 5, 9, 1, 8 into ascending order:

main.cs
int[] numbers = new int[] { 5, 9, 1, 8 };
Array.Sort(numbers);

foreach (int num in numbers)
{
    Console.Write(num + " ");
}
127 chars
8 lines

This will output 1 5 8 9, which is the sorted version of the original array.

related categories

gistlibby LogSnag