Last active
November 19, 2015 19:17
-
-
Save ivankahl/99d426666fe1486f1859 to your computer and use it in GitHub Desktop.
Visual C#: Linear Sorting Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static int[] SelectionSort(int[] items) | |
{ | |
// Loop through each element | |
for (int i = 0; i < items.Length - 1; i++) | |
// Loop through each element afterwards | |
for (int j = i + 1; j < items.Length; j++) | |
// Check if the first item is bigger than the second item | |
if (items[i] > items[j]) | |
{ | |
// If it is, swap the two values | |
int tmp = items[i]; | |
items[i] = items[j]; | |
items[j] = tmp; | |
} | |
return items; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment