Skip to content

Instantly share code, notes, and snippets.

View jgable's full-sized avatar

Jacob Gable jgable

  • Making Other People Money
  • Redwood City, CA
  • X @jacob4u2
View GitHub Profile
@paullewis
paullewis / gist:1982121
Created March 5, 2012 23:44
Mergesort in JavaScript
/**
* An implementation for Mergesort. Less efficient
* than Quicksort. Again, you'd just use Array.sort
* but if you found yourself unable to use that
* there's always this option.
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
@paullewis
paullewis / gist:1981455
Created March 5, 2012 22:03
Quicksort in JavaScript
/**
* An implementation for Quicksort. Doesn't
* perform as well as the native Array.sort
* and also runs the risk of a stack overflow
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
* array.push(Math.round(Math.random() * 100));