C - Insertion sort
void isort_c(unsigned *a, int n) { int k; for (k = 1; k < n; ++k) { int key = a[k]; int i = k - 1; while ((i >= 0) && (key < a[i])) { a[i + 1] = a[i]; --i; } a[i + 1] = key; } }
DZone Snippets > scvalex > insertionsort
12366 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
void isort_c(unsigned *a, int n) { int k; for (k = 1; k < n; ++k) { int key = a[k]; int i = k - 1; while ((i >= 0) && (key < a[i])) { a[i + 1] = a[i]; --i; } a[i + 1] = key; } }