Skip to content

Instantly share code, notes, and snippets.

@shogonir
Created June 2, 2015 05:13
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 shogonir/88336857d41a73033c62 to your computer and use it in GitHub Desktop.
Save shogonir/88336857d41a73033c62 to your computer and use it in GitHub Desktop.
insertion sort implemented with C
void insertion_sort (int n, int *a) {
int i, j, swap;
for (i=1; i<n; i++) {
j = i-1;
while (j>=0 && a[j]>a[j+1]) {
swap = a[j];
a[j] = a[j+1];
a[j+1] = swap;
j--;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment