Hello Guys! Welcome To My Blog!
Sort Array without using any Inbuilt in Ascending Order Function in C#
Today we will be learn how to sort array without using any inbuilt function in C# in Ascending Order!
In this code we will be use 2 for loop
Lets see how will be happen
using System;
namespace sort
{
class Program
{
static void Main(string[] args)
{
int sort = 0;
int[] counting = { 5, 6, 3, 7, 23 ,22};
for (int i = 0; i < counting.Length; i++)
{
for (int j = i; j < counting.Length; j++)
{
if (counting[i] > counting[j])
{
sort = counting[i];
counting[i] = counting[j];
counting[j] = sort;
}
}
Console.WriteLine(counting[i]);
}
}
}
}
OUTPUT!
3
5
6
7
22
23
Comments
Post a Comment