Skip to content

Instantly share code, notes, and snippets.

@jp26jp
Last active February 22, 2018 16:10
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/05f61b21e90db4c0212a86a605d773ca to your computer and use it in GitHub Desktop.
Save jp26jp/05f61b21e90db4c0212a86a605d773ca to your computer and use it in GitHub Desktop.
Insertion sort algorithm
void insertionSort(int[] array)
{
for (int i = 1; i < array.length; i++)
{
int index = i, indexValue = array[index];
while (index > 0 && array[index - 1] > indexValue) array[index] = array[--index];
array[index] = indexValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment