Skip to content

Instantly share code, notes, and snippets.

@Twelve0fNine
Created February 21, 2014 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Twelve0fNine/9140525 to your computer and use it in GitHub Desktop.
Save Twelve0fNine/9140525 to your computer and use it in GitHub Desktop.
How to simply sort an Array
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sort_Array
{
class Program
{
static void Main(string[] args)
{
int count;
Console.WriteLine("How many Numbers you like to sort?\n");
count = Convert.ToInt32(Console.ReadLine());
int[] arrNumbers = new int[count];
for (int i = 0; i < count; i++)
{
int j= i+1;
Console.WriteLine("Enter Number " + j);
arrNumbers[i] = Convert.ToInt32(Console.ReadLine());
}
Array.Sort(arrNumbers);
Console.Clear();
for (int i = 0; i < arrNumbers.Length; i++)
{
int j = i + 1;
//Console.WriteLine("Nr."+j+ " is: "+arrNumbers[i]+"\n");
Console.Write(arrNumbers[i] + " ");
}
Console.WriteLine("\n\nPress any Key to Exit ...");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment