Last active
December 28, 2020 12:42
-
-
Save YonLiud/a4dcb247ab21a21c6756612f5a1993ca to your computer and use it in GitHub Desktop.
Selection Array Sorting Method - C#
This file contains hidden or 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
static int[] SelectionSort(int[] inputArray) | |
{ | |
int[] outputArray = inputArray; | |
int temp, smallest; | |
for (int i = 0; i < ARRAY_SIZE; i++) | |
{ | |
smallest = i; | |
for (int j = i + 1; j < ARRAY_SIZE; j++) | |
{ | |
if (outputArray[j] < outputArray[smallest]) | |
{ | |
smallest = j; | |
} | |
} | |
temp = outputArray[smallest]; | |
outputArray[smallest] = outputArray[i]; | |
outputArray[i] = temp; | |
} | |
return outputArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment