Skip to content

Instantly share code, notes, and snippets.

@alajmo
Last active March 29, 2016 11:02
Show Gist options
  • Save alajmo/dfa6765e345c08b850cc to your computer and use it in GitHub Desktop.
Save alajmo/dfa6765e345c08b850cc to your computer and use it in GitHub Desktop.
Sorting algorithms written in javascript.
// Insertion sort.
var i = a.length;
var j;
while (i--) {
j = i;
while (j > 0 && a[j - 1] > a[j]) {
a[j] = a[j - 1] + (a[j - 1] = a[j]) - a[j];
j += 1;
}
}
@alajmo
Copy link
Author

alajmo commented Jan 23, 2016

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