Created
June 27, 2016 00:23
-
-
Save JiLiZART/7db28e46d9bf19f3b2b19dbbcbf2087b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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