c# sort for loop
C#
public static void Main(string[] args)
{
int[] arr = { 5,4,3,2,1 };
Sorting(arr);
}
public static void Sorting(int[] arr)
{
int length = arr.Length;
for (int i = 0; i < length - 1; i++)
{ //length-1 b/c i+1 will put you OOB
if (arr[i] > arr[i + 1])
{//For descending order...skips to next index if false
int temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
i = -1; //sort from lowest out of order index
}
}
foreach (int item in arr)
{
Console.WriteLine(item);
}
}
Also in C#:
- Title
- c# zip a file
- Category
- C#
- Title
- unity button interactable
- Category
- C#
- Title
- count the number of notes in a given amount c#
- Category
- C#
- Title
- c# convert byte to char
- Category
- C#
- Title
- C# save pdf stream to file
- Category
- C#
- Title
- 5 second timer in c#
- Category
- C#
- Title
- how to change text to bold through script unity
- Category
- C#
- Title
- how to get the askii code of a char in c#
- Category
- C#
- Title
- c# get list of all class fields
- Category
- C#
- Title
- write last line txt file c#
- Category
- C#
- Title
- c# remove last value from list
- Category
- C#
- Title
- dynamically add rows to datagridview c#
- Category
- C#
- Title
- unity calculate path
- Category
- C#
- Title
- vb.net drag window without titlebar
- Category
- C#
- Title
- Length = '((System.Net.RequestStream)RequestStream).Length' threw an exception of type 'System.NotSupportedException'
- Category
- C#
- Title
- c# get desktop path
- Category
- C#
- Title
- c# read file stream
- Category
- C#
- Title
- modificare una strinfa in c#
- Category
- C#
- Title
- degree to radians c#
- Category
- C#
- Title
- array copy c#
- Category
- C#
- Title
- hot to move pobject unity
- Category
- C#
- Title
- dynamic group by expression C#
- Category
- C#
- Title
- how to get the last element in an array in c#
- Category
- C#
- Title
- unity cast int to float
- Category
- C#
- Title
- c# length of array
- Category
- C#
- Title
- c# image to byte array
- Category
- C#
- Title
- C# get object property name
- Category
- C#
- Title
- c# read char
- Category
- C#
- Title
- winforms timer c#
- Category
- C#
- Title
- what function is called just before the a script is ended c#
- Category
- C#
- Title
- asp.net c# set session timeout
- Category
- C#
- Title
- rotatearound unity
- Category
- C#
- Title
- .net core copy file in folder to root
- Category
- C#
- Title
- how to clear console in c#
- Category
- C#
- Title
- convert array object to int[] c#
- Category
- C#
- Title
- unity find object by name
- Category
- C#
- Title
- epplus excel vb.net
- Category
- C#
- Title
- linq c# where condition
- Category
- C#
- Title
- c# regex replace
- Category
- C#
- Title
- bitmap to byte array c#
- Category
- C#
- Title
- c# polymorphism
- Category
- C#
- Title
- why is c# say ; expected
- Category
- C#
- Title
- to list c#
- Category
- C#
- Title
- basic sorting algorithms c#
- Category
- C#
- Title
- unity how to change rotation
- Category
- C#
- Title
- c# get all inherited classes of a class
- Category
- C#
- Title
- get set c#
- Category
- C#
- Title
- how to copy one array value to another without reference c#
- Category
- C#
- Title
- unity serializefield
- Category
- C#
- Title
- repeater itemdatabound event in c#
- Category
- C#
- Title
- c# catch two exceptions in one block
- Category
- C#
- Title
- c# ref
- Category
- C#
- Title
- .sh script: check if file exist
- Category
- C#
- Title
- unity next scene
- Category
- C#
- Title
- how to get odd saturday in a month in c#
- Category
- C#
- Title
- get permission to write read file and directory on file system C#
- Category
- C#
- Title
- c# how to compare 2 dates without time
- Category
- C#
- Title
- Random number unity
- Category
- C#
- Title
- c# if statement
- Category
- C#
- Title
- c# LCP
- Category
- C#
- Title
- choose random gameobject from a gameobject list
- Category
- C#
- Title
- c# global enumerator
- Category
- C#
- Title
- What is a class in c#
- Category
- C#
- Title
- c# reverse string
- Category
- C#
- Title
- what is using static in c#
- Category
- C#
- Title
- fahrenheit to celsius c#
- Category
- C#
- Title
- remove items from list c# condition
- Category
- C#
- Title
- c# arraylist contains
- Category
- C#
- Title
- unity instantiate
- Category
- C#
- Title
- unity on trigger enter
- Category
- C#
- Title
- how to compare datetime in c#
- Category
- C#
- Title
- Celsius to Fahrenheit c#
- Category
- C#
- Title
- unity rotation
- Category
- C#
- Title
- The type or namespace name 'Scrollbar' could not be found
- Category
- C#
- Title
- convert string to datetime c#
- Category
- C#
- Title
- c# how to check if two lists have same values
- Category
- C#
- Title
- leantween id
- Category
- C#
- Title
- .net core check if linux
- Category
- C#
- Title
- c# remove character from string at index
- Category
- C#
- Title
- unity rotate around point
- Category
- C#
- Title
- c#if
- Category
- C#
- Title
- c# list.foreach
- Category
- C#
- Title
- unity deactive all object in list
- Category
- C#
- Title
- c# Sleep
- Category
- C#
- Title
- c# get object property value by name
- Category
- C#
- Title
- .net core executenonqueryasync transaction
- Category
- C#
- Title
- make a list c#
- Category
- C#
- Title
- parsing string to int without format exception c#
- Category
- C#
- Title
- C# array to string
- Category
- C#
- Title
- unity face direction of movement
- Category
- C#
- Title
- c# int
- Category
- C#
- Title
- formula calculating distance coordinates latitude longitude c#
- Category
- C#
- Title
- winforms c# add data to datagridview with a button
- Category
- C#
- Title
- c# make http request
- Category
- C#
- Title
- c# new dictionary linq
- Category
- C#
- Title
- c# variable
- Category
- C#
- Title
- unity3d invector expand fsm controller
- Category
- C#
- Title
- javascript append
- Category
- C#
- Title
- debug.log
- Category
- C#
- Title
- insert new item listview c#
- Category
- C#