Skip to content

Instantly share code, notes, and snippets.

@Prince781
Created June 2, 2014 16:42
Show Gist options
  • Save Prince781/9b2a3fb4ccae678952e8 to your computer and use it in GitHub Desktop.
Save Prince781/9b2a3fb4ccae678952e8 to your computer and use it in GitHub Desktop.
Simple insertion sort
void insertion_sort(int *arr, int len) {
int p;
for (p=1; p<len; p++) {
int n = arr[p], p2 = p;
while (p2 > 0 && n < arr[p2-1])
arr[p2] = arr[--p2];
arr[p2] = n;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment