Instantly share code, notes, and snippets.

Embed
What would you like to do?
void insertSort(int a[], int size) {
for (int i=1; i<size; i++) {
int t = a[i];
int j=i-1;
for (; j>=0; j--) {
if (a[j] > t) {
a[j+1] = a[j];
} else {
break;
}
}
a[j+1] = t;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment