Skip to content

Instantly share code, notes, and snippets.

@YonLiud
Last active December 28, 2020 12: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 YonLiud/a4dcb247ab21a21c6756612f5a1993ca to your computer and use it in GitHub Desktop.
Save YonLiud/a4dcb247ab21a21c6756612f5a1993ca to your computer and use it in GitHub Desktop.
Selection Array Sorting Method - C#
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