Skip to content

Instantly share code, notes, and snippets.

@JiLiZART
Created June 27, 2016 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JiLiZART/7db28e46d9bf19f3b2b19dbbcbf2087b to your computer and use it in GitHub Desktop.
Save JiLiZART/7db28e46d9bf19f3b2b19dbbcbf2087b to your computer and use it in GitHub Desktop.
function sort(nums)
{
if (!nums.length) return nums;
var a = [], b = [], p = nums[0];
for (var i = 1; i < nums.length; i++)
{
if (nums[i] < p)
a[a.length] = nums[i];
else
b[b.length] = nums[i];
}
return sort(a).concat(p, sort(b));
}
var some = [128, 55, 44, 11, 22, 33, 256];
console.log(sort(some));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment