Skip to content

Instantly share code, notes, and snippets.

@jp26jp
Last active February 22, 2018 16:11
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 jp26jp/5e86e0383af26fb31221e10094c6eb67 to your computer and use it in GitHub Desktop.
Save jp26jp/5e86e0383af26fb31221e10094c6eb67 to your computer and use it in GitHub Desktop.
Selection sort algorithm
void selectionSort(int[] array)
{
for (int i = 0; i < array.length - 1; i++)
{
int index = i;
for (int j = i + 1; j < array.length; j++)
if (array[j] < array[index])
index = j;
int temp = array[i];
array[i] = array[index];
array[index] = temp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment