Created
September 3, 2014 01:08
-
-
Save pnispel/00da7df9be77a613e30e to your computer and use it in GitHub Desktop.
insertion sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int * sort (int arr [], int len) { | |
for (int i = 1; i < len; i++) { | |
int key = arr[i]; | |
int j = i - 1; | |
while (j >= 0 && arr[j] > key) { | |
arr[j + 1] = arr[j]; | |
j = j - 1; | |
} | |
arr[j + 1] = key; | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment