Skip to content

Instantly share code, notes, and snippets.

@renatoargh
Created July 24, 2012 21:04
Show Gist options
  • Select an option

  • Save renatoargh/3172649 to your computer and use it in GitHub Desktop.

Select an option

Save renatoargh/3172649 to your computer and use it in GitHub Desktop.
function insertionSort(array, ascending){
if(ascending === undefined)
ascending = true;
for(i = 1; i < array.length; i++){
var key = array[i];
var j = i - 1;
while(j >= 0 && (array[j] > key === ascending)){
array[j + 1] = array[j];
j--;
}
array[j + 1] = key;
}
}
@oyieramos
Copy link

there is no return statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment